-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (47 loc) · 1.88 KB
/
main.py
File metadata and controls
58 lines (47 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import copy
from time import sleep
__author__ = 'Nicklas Boerjesson'
__version__ = '0.1'
from kivy.app import App
from kivy.utils import platform
platform = platform()
from gui.settings import SettingsFrame
from plyer import notification
import os
from shutil import copy
import sys
# If not, large directory structures will cause an error on Android
sys.setrecursionlimit(1000)
class OptimalFileSyncApp(App):
settingsframe = None
def build(self):
try:
# Find home dir
if platform == "android":
_home = "/storage/emulated/0/Android/data/"
else:
_home = os.path.expanduser("~")
# Check if there is a settings file there
_config_path = os.path.join(_home, "se.optimalbpm.optimal_file_sync/config.txt")
# Raise error if non existing config
if not os.path.exists(_config_path):
if not os.path.exists(os.path.join(_home, "se.optimalbpm.optimal_file_sync")):
os.mkdir(os.path.join(_home, "se.optimalbpm.optimal_file_sync"))
if platform == "android":
copy("default_config_android.txt", _config_path)
else:
copy("default_config_linux.txt", _config_path)
notification.notify("Optimal File Sync Service", "First time, using default config.")
self.settingsframe = SettingsFrame()
self.settingsframe.init(_cfg_file=_config_path)
return self.settingsframe
except Exception as e:
notification.notify("Optimal File Sync Service", "Error finding config :" + str(e))
def on_stop(self):
self.settingsframe.save_settings()
if __name__ == "__main__":
try:
OptimalFileSyncApp().run()
except Exception as e:
notification.notify(title="Optimal Backup error:", message = str(e))
raise