finished bgservice

This commit is contained in:
Rushil Umaretiya 2020-06-16 23:47:03 -04:00
parent 8b11e2defe
commit aecdb3b4f1

View File

@ -88,11 +88,9 @@ def main():
USER = data['username']
print(data['username'])
if data['is_student']:
empty_logs()
bg.watch_dir()
# bg.watch_dir()
# atexit.register(stop_bg_service)
studentCLI(USER, PWD)
atexit.register(stop_bg_service)
else:
teacherCLI(USER, PWD)
@ -103,26 +101,14 @@ def stop_bg_service():
print("good")
bg.stop_watching()
print('also')
cur_path = os.path.dirname(__file__)
cur_path = os.path.dirname('') # Change to definite SkoolOS dir
print('yes')
newpath = os.path.relpath('bgservice/SkoolOS/logs')
newpath = os.path.relpath('bgservice/SkoolOS/logs/')
logText = ""
with open(newpath, 'r') as logfile:
with open(newpath + '/skooloslog', 'r') as logfile:
logfile.read()
print (logText)
def empty_logs():
logs_folder = os.path.dirname(__file__) + 'bgservice/SkoolOS/logs/'
for filename in os.listdir(logs_folder):
file_path = os.path.join(logs_folder, filename)
try:
if os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception as e:
print('Failed to delete %s. Reason: %s' % (file_path, e))