-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem.py
More file actions
44 lines (32 loc) · 1.18 KB
/
system.py
File metadata and controls
44 lines (32 loc) · 1.18 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
from watchdog.events import FileSystemEventHandler
from ThingSync import main
import subprocess
import logging
import glob
import os
class FileChangeHandler(FileSystemEventHandler):
def __init__(self, target_file, state, service):
self.target_file = os.path.abspath(target_file)
self.state = state
self.service = service
def on_modified(self, event):
main(self.state, self.service)
def caffeinate() -> None:
PID = os.getpid()
logging.debug(f"Caffeinating process number {PID}...")
subprocess.Popen(['caffeinate', '-s', '-w', str(PID)])
logging.debug(f"Caffeination successfull for process {PID}")
def things_database_file_path() -> str:
DEFAULT_FILEPATH_31616502 = (
"~/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac"
"/ThingsData-*/Things Database.thingsdatabase/main.sqlite"
)
DEFAULT_FILEPATH_31516502 = (
"~/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac"
"/Things Database.thingsdatabase/main.sqlite"
)
try:
DEFAULT_FILEPATH = next(glob.iglob(os.path.expanduser(DEFAULT_FILEPATH_31616502)))
except StopIteration:
DEFAULT_FILEPATH = os.path.expanduser(DEFAULT_FILEPATH_31516502)
return DEFAULT_FILEPATH