attribution_report/utils.py

40 lines
990 B
Python
Raw Normal View History

2015-07-17 20:17:15 +00:00
__author__ = 'tyrelsouza'
import os
import json
2015-07-20 16:23:44 +00:00
import threading
import time
2015-07-17 20:17:15 +00:00
def get_dropbox_dir():
"""
Windows and Mac get dropox dir for Business or fallback to personal
"""
if os.name == "nt":
dropbox_file = os.path.join(os.getenv('APPDATA'), 'Dropbox', 'info.json')
else:
dropbox_file = os.path.expanduser("~/.dropbox/info.json")
with open(dropbox_file) as dbf:
dbconfig = json.loads(dbf.read())
if "business" in dbconfig:
dropbox_dir = dbconfig['business']['path']
elif "personal" in dbconfig:
dropbox_dir = dbconfig['personal']['path']
else:
dropbox_dir = os.path.expanduser("~")
2015-07-20 16:23:44 +00:00
return dropbox_dir
class ThreadedTask(threading.Thread):
def __init__(self, queue, report):
threading.Thread.__init__(self)
self.queue = queue
self.report = report
def run(self):
self.report.run()
self.report.save()
self.queue.put("Task finished")