Example #1
0
 def get_executables(self):
     drive_letters = []
     
     # New dict entry for the executables. They are going to be part of a sub-dict.
     self.settings['Settings']['Executables'] = {}
     
     # For loop to find all the drive letters in the system.
     for drive in ascii_uppercase:
         if path.exists(drive + ':\\'):
             drive_letters.append(drive)
     
     # Check to see if the user's system is either 64 or 32 bit.
     if self.settings['Settings']['Architecture'] == 'AMD64':
         architecture = '64'
     else:
         architecture = '32'
     
     # For loop which searches system for the specified executable. Once found they are added
     # to the 'Executables' dict created earlier.
     for drive in drive_letters:
         for root, dirs, files in walk('{0}:\\cygwin{1}\\'.format(drive, architecture)):
             if 'rsync.exe' in files:
                 self.settings['Settings']['Executables']['rsync'] = \
                 str(path.join(root, 'rsync.exe'))
             if 'curl.exe' in files:
                 self.settings['Settings']['Executables']['curl'] = \
                 str(path.join(root, 'curl.exe'))
     
     # Use helper function to write out the json file which will include the 'Executables' dict.
     proc_helpers.parse_json(self.settings, 'w')
     
     return self.settings
Example #2
0
 def cli_questions(self):
     self.settings['Settings']['Questions'] = {}
     
     print('Welcome to Kadup backup!\n')
     self.settings['Settings']['Questions']['backup_dir'] = \
         proc_helpers.get_valid_path('backup', self.settings['Settings']['Operating_System'])
     self.settings['Settings']['Questions']['dest_dir'] = \
         proc_helpers.get_valid_path('destination', self.settings['Settings']['Operating_System'])
     self.settings['Settings']['Questions']['one_time'] = \
         proc_helpers.get_valid_yes_no('Is this a one time task (y/n)? ')
             
     if self.settings['Settings']['Questions']['one_time'] is 'n' or \
     self.settings['Settings']['Questions']['one_time'] is 'no':
         print('Please answer the following questions to define time and frequency of the backup task')
         self.settings['Settings']['Questions']['schedule'] = {}
         self.settings['Settings']['Questions']['schedule']['start_time'] = \
             input('Enter the time, in 24-hour format HH:MM, that kadup should begin backing up: ')
         self.settings['Settings']['Questions']['schedule']['interval'] = \
             input('Should this backup run DAILY, WEEKLY, or MONTHLY? ')
         
         if self.settings['Settings']['Questions']['schedule']['interval'] == 'WEEKLY' or \
         self.settings['Settings']['Questions']['schedule']['interval'] == 'weekly':
             self.settings['Settings']['Questions']['schedule']['day_of_week'] = \
                 input('Which day of the week do you want kadup to run (MON-SUN)? ')
                 
         if self.settings['Settings']['Questions']['schedule']['interval'] == 'MONTHLY' or \
         self.settings['Settings']['Questions']['schedule']['interval'] == 'monthly':
             self.settings['Settings']['Questions']['schedule']['day_of_month'] = \
                 input('Which day of the month do you want kadup to run (1-31)? ')
     
     proc_helpers.parse_json(self.settings, 'w')
     
     return self.settings