__author__ = "Remigius Kalimba"
"""Add a timer so it does this automatically everyday at a set time"""

import pickle
import crontab as CronTab
import json
import os
import sys
from subprocess import call

import getpass

pwd = os.path.dirname(os.path.abspath(__file__))


def schedule_start(folders):

    """Starts a schedule to organise the desktop once a day"""

    with open('./settings.txt', 'wb') as setting_file:
        pickle.dump(folders, setting_file)
    if sys.platform == 'darwin' or sys.platform == 'linux':
        my_cron = CronTab(user=getpass.getuser())
        job = my_cron.new(command=str(sys.executable + ' ' + pwd + '/cronCleanUp.py'),
                          comment='OrganiseDesktop')
        job.day.every(1)
        my_cron.write()
    else:
        if not os.path.isfile(pwd + '\\cronCleanUp.pyw'):
            call('copy' + pwd + '\\cronCleanUp.py' + pwd + '\\cronCleanUp.pyw', shell=True)
        call('SCHTASKS /Create /SC DAILY /TN OrganiseDesktop /TR' + pwd + '\\cronCleanUp.pyw /F',
             shell=True)


def schedule_end():

    """Removes the schedule if one is defined"""

    os.remove('./settings.txt')
    if sys.platform == 'darwin' or sys.platform == 'linux':
        my_cron = CronTab(user=getpass.getuser())
        my_cron.remove_all(comment='OrganiseDesktop')
        my_cron.write()
    else:
        call('SCHTASKS /Delete /TN OrganiseDesktop /F',
                 shell=True)
@@ -215,16 +215,17 @@
 etpass%0A%0A
+%0A
 pwd = os
@@ -459,16 +459,25 @@
 g_file)%0A
+        %0A
     if s
@@ -570,32 +570,41 @@
 pass.getuser())%0A
+        %0A
         job = my
@@ -719,32 +719,41 @@
 ganiseDesktop')%0A
+        %0A
         job.day.
@@ -761,16 +761,25 @@
 very(1)%0A
+        %0A
         
@@ -954,16 +954,29 @@
 l=True)%0A
+            %0A
         
@@ -1195,16 +1195,21 @@
 s.txt')%0A
+    %0A
     if s
@@ -1380,32 +1380,41 @@
 my_cron.write()%0A
+        %0A
     else:%0A      
@@ -1459,24 +1459,24 @@
 esktop /F',%0A
-
             
@@ -1471,28 +1471,29 @@
                  shell=True)
+%0A

Update cronController.py