Esempio n. 1
0
 def upload_to_drive():
     google_client = DriveClient()
     google_client.upload_file(csv_name)
     App.get_running_app().settings.update_settings(update_time=time_str)
     os.remove(csv_name)            
     InformationPopup('File uploaded')
     Logger.info('CustomerHandler: upload thread finished')
Esempio n. 2
0
 def download_from_drive():
     google_client = DriveClient()
     csv_filename = google_client.download_latest_csv()
     new_customers = self.load_csv(csv_filename)
     #drop customer table and replace the customers with the downloaded customers
     if new_customers:
         self.customers = []
         self.drop_customers()
         self.enable_databases()
         for c in new_customers:
             self.create_new_account(c)
     
     App.get_running_app().man.get_screen("acc_manage").on_pre_enter()
     InformationPopup('File downloaded')
     Logger.info('CustomerHandler: download thread finished')
Esempio n. 3
0
 def download_from_drive():
     google_client = DriveClient()
     csv_filename = google_client.download_latest_csv(full_path = self.full_path)
     new_customers = self.load_csv(csv_filename)
     #drop customer table and replace the customers with the downloaded customers
     if new_customers:
         self.customers = []
         self.drop_customers()
         self.enable_databases()
         for c in new_customers:
             self.create_existing_account(c)
     
     App.get_running_app().man.get_screen("acc_manage").on_pre_enter()
     InformationPopup('File downloaded')
     Logger.info('CustomerHandler: download thread finished')
Esempio n. 4
0
 def backup_customers(self):
     csv_name, time_str = self.save_csv()
     
     google_client = DriveClient()
     #upload to drive inside a different thread not to block the ui thread
     def upload_to_drive():            
         google_client.upload_file(filename = csv_name, file_path= os.path.join( self.full_path, 'logs') )            
         os.remove(os.path.join(self.full_path, 'logs', csv_name))            
         InformationPopup('File uploaded')
         Logger.info('CustomerHandler: upload thread finished')
         App.get_running_app().settings.update_settings(update_time=time_str)
     
     thread1 = threading.Thread(group=None,target=upload_to_drive)
     thread1.start()         
     Logger.info('CustomerHandler: backup customers called')
    def download_settings(self):

        google_client = DriveClient()

        #download to drive inside a different thread not to block the ui thread
        def download_settings_thread():
            downloaded_filename = google_client.download_settings(
                full_path=self.full_path)

            if (downloaded_filename):
                InformationPopup('Settings downloaded')

            else:
                InformationPopup('Downloading settings failed')
            Logger.info('Settings: downloading settings thread finished')

        thread1 = threading.Thread(group=None, target=download_settings_thread)
        thread1.start()
        Logger.info('CustomerHandler: backup customers called')