Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 #192

Open
wants to merge 101 commits into
base: python3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
b6d2053
Update debug.py
Feb 24, 2021
0bf9013
Update shutdown.py
Feb 24, 2021
2b352e1
Update helper.py
Feb 25, 2021
4a2c00c
Update debug.py
Feb 27, 2021
ba3b6ab
Update helper.py
Feb 27, 2021
66eb329
Update base.py
Mar 8, 2021
079d761
Update display.py
Mar 9, 2021
2a2dc70
Update servicemanager.py
Mar 11, 2021
cd47273
Update oauth.py
Mar 11, 2021
6633fc8
Update oauthlink.py
Mar 11, 2021
4dc9064
Update README.md
May 4, 2021
fa84132
Update svc_googlephotos.py
May 5, 2021
f05a321
Update colormatch.py
May 5, 2021
aff4765
Update README.md
May 5, 2021
91bc4ec
Update helper.py
May 5, 2021
e06d83e
Update README.md
May 5, 2021
6a36c79
Update helper.py
May 5, 2021
b9c8f50
Update helper.py
May 5, 2021
cf5deeb
Update helper.py
May 5, 2021
e23c136
Update colormatch.py
May 18, 2021
ac4ed48
Update colormatch.py
May 18, 2021
f1f2548
Update colormatch.py
May 18, 2021
4a251b6
Update colormatch.py
May 18, 2021
9617546
Update colormatch.py
May 18, 2021
7f89b2d
Update colormatch.py
May 18, 2021
914b09e
Update colormatch.py
May 19, 2021
91b767c
Update colormatch.py
May 19, 2021
1992a47
Update colormatch.py
May 19, 2021
c8b1864
Update colormatch.py
May 19, 2021
91c3e4e
Update colormatch.py
May 19, 2021
8e8845e
reduce Warnings and clean up update script
May 19, 2021
169276e
Update README.md
May 19, 2021
781dacb
Update README.md
May 19, 2021
15c5fcc
Update README.md
May 19, 2021
a12cc11
update to install instructions
May 19, 2021
072da2d
Re-written temp logic
May 21, 2021
108928e
syntax bug
May 21, 2021
8cc2028
Monitor brightness fix
May 21, 2021
1e1ca4e
Run from port 80
May 21, 2021
6487cb7
Update README.md
May 23, 2021
e13b98e
Update svc_usb.py
May 23, 2021
576238e
Merge pull request #1 from dadr/Philip
Jun 8, 2021
cf1e744
Update README.md
Jun 8, 2021
c6e4581
Update Readme
Jun 8, 2021
7f31f27
Update Readme
Jun 8, 2021
2c6ff44
point repo to mrworf
Jun 8, 2021
8a1c664
Update README.md
Jun 8, 2021
5ffb18a
Screen Standby
Jun 9, 2021
fba4690
Update README.md
Jun 9, 2021
3cc375a
Update README.md
Jun 9, 2021
e7baad4
Update maintenance.py
Jun 11, 2021
8dfee5b
screen buttons
Jun 11, 2021
9ee63d6
Update maintenance.py
Jun 11, 2021
d4142df
Merge pull request #2 from dadr/feature/screen-off-url
Jun 12, 2021
f43294f
Update README.md
Jun 12, 2021
a3b205a
Finish feature
Jun 12, 2021
9afc531
Bugfix
Jun 12, 2021
db9057d
Update main.js
Jun 12, 2021
92c1cce
Update main.js
Jun 12, 2021
422bbc3
Return web pages
Jun 12, 2021
e0aa548
Update maintenance.py
Jun 12, 2021
df90112
Update maintenance.py
Jun 12, 2021
e736bd5
Merge branch 'python3' into feature/backup
Jun 12, 2021
62dad93
Merge pull request #3 from dadr/feature/backup
Jun 12, 2021
2e94072
Update README.md
Jun 14, 2021
ec390d9
Update base.py
Jun 17, 2021
3732562
Work with files
Jun 17, 2021
2e52fa7
Update main.js
Jun 17, 2021
7794c9b
Update upload.py
Jun 17, 2021
bbd453e
Update maintenance.py
Jun 17, 2021
9387079
Finish Download
Jun 17, 2021
936764c
Upload config changes
Jun 17, 2021
b73f91f
Style adjust
Jun 17, 2021
70d86c6
Update upload.py
Jun 17, 2021
8883555
Update upload.py
Jun 17, 2021
228331e
restart
Jun 17, 2021
29db0b7
Merge pull request #4 from dadr/feature/backup
Jun 17, 2021
b5d9ae7
Update main.html
Jun 17, 2021
566254b
Update upload.py
Jun 17, 2021
65e5d11
Update main.js
Jun 17, 2021
2f96e5c
Merge pull request #5 from dadr/feature/backup
Jun 17, 2021
d532232
Update main.html
Jun 18, 2021
61d09c3
Update main.html
Jun 18, 2021
fbf4653
Config Page Formatting
Jun 18, 2021
020e6ef
Update main.html
Jun 18, 2021
c3e6f01
Update main.html
Jun 18, 2021
38b97d9
Update main.html
Jun 18, 2021
d33f8db
Merge pull request #6 from dadr/feature/Configuration
Jun 18, 2021
7a74b7f
Initial partial commit
Jul 5, 2021
2ac8c75
Second set of work
Jul 8, 2021
81d5977
Rework restore to run as separate process.
Aug 17, 2021
96c993a
Create Version File
Jan 10, 2022
a584370
Merge pull request #8 from dadr/feature/backup
dadr Jan 10, 2022
b215564
Final Bugfixes for backup feature
Jan 17, 2022
ad2a43e
Merge pull request #9 from dadr/feature/backup
dadr Jan 17, 2022
42e5130
Last Bugfixes
Jan 17, 2022
da233e9
Merge pull request #10 from dadr/feature/backup
dadr Jan 17, 2022
6e57772
Error checking on tar
Jan 18, 2022
8ca44ca
Merge pull request #11 from dadr/feature/backup
dadr Jan 18, 2022
471c4f8
Indent error
Jan 18, 2022
95ecaa1
Merge pull request #12 from dadr/feature/backup
dadr Jan 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions routes/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ def handle(self, app, cmd):
elif cmd == 'ssh':
subprocess.call(['systemctl', 'restart', 'ssh'], stderr=self.void)
return self.jsonify({'ssh': True})
elif cmd == 'backup':
subprocess.call(['tar', '-czf', '/boot/settings.tar.gz', '/root/photoframe_config'], stderr=self.void)
Copy link
Owner

@mrworf mrworf Jun 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts here. The backup should include some meta info, preferably a JSON file with the following details:

  • Last commit from running branch
  • Which branch
  • What version of the export tool was used (in case we need to handle different scenarios on restore). For the initial version, it should simply be 1 :-)

Complete folder path should also be avoided since we cannot assume /root/ will always be the destination (in the restore).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also a risk that files change during export of configuration but I think it's less of a concern

return 'Backup Successful', 200
elif cmd == 'restore':
if os.path.isfile("/boot/settings.tar.gz"):
subprocess.call(['tar', '-xzf', '/boot/settings.tar.gz', '-C', '/'], stderr=self.void)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be done within the frame, since we're multi-threaded, instead it's better to have a tool that you kick off which will shutdown the frame service, update it and then restart it. This also gives us the option to add extra steps during import of older configurations.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the restore here does not remove the old configuration, so you run a big risk of getting a really jumbled setup after doing restore.

One way to do restore without having downtime is to restore into /root/photoframe_config_restore and once that is done, validate configuration and then finally shutdown, swap folders and start again. Once it successfully starts, it should delete the old setup. This also gives a safety net should something fail, allowing rollback.

subprocess.Popen('systemctl restart frame', shell=True)
return 'Restore settings complete', 200
else:
return 'No restore file found', 404
elif cmd == 'standby':
self.timekeeper.setExternalStandby(True)
return self.jsonify({'standby': self.timekeeper.getExternalStandby()})
Expand Down
19 changes: 19 additions & 0 deletions static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,25 @@ $("#reboot").click(function() {
}
});

$("#backup").click(function() {
if (confirm("Backup current settings to /boot/settings.tar.gz ?")) {
$.ajax({
url:"/maintenance/backup"
}).done(function (){
});
}
});

$("#restore").click(function() {
if (confirm("This will remove the current configuration and restore saved settings from /boot/settings.tar.gz ?")) {
$.ajax({
url:"/maintenance/restore"
}).done(function(){
rebootWatch();
});
}
});

$("#shutdown").click(function() {
if (confirm("Are you sure you want to POWER OFF the frame?")) {
$.ajax({
Expand Down
8 changes: 5 additions & 3 deletions static/template/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,16 @@ <h1><a href="https://github.com/mrworf/photoframe">PhotoFrame Configuration</a>
</div>
<div>
<input type="button" id="update" value="Check for update">
<div style="display: inline-block; width: 100px"></div>
<div style="display: inline-block; width: 25px"></div>
<input type="button" id="reboot" value="Reboot">
<input type="button" id="shutdown" value="Power off">
<div style="display: inline-block; width: 100px"></div>
<div style="display: inline-block; width: 25px"></div>
<input type="button" id="forgetMemory" title="Show images that have already been displayed" value="Forget Memory">
<input type="button" id="clearCache" title="In case you have recently cropped or edited your photos" value="Clear Cache">
<input type="button" id="reset" value="Factory Reset">
<div style="display: inline-block; width: 100px"></div>
<input type="button" id="backup" value="Backup Settings">
<input type="button" id="restore" value="Restore Settings">
<div style="display: inline-block; width: 25px"></div>
<input type="button" id="debug" value="Log report">
</div>
</div>
Expand Down