def post(self): if self.authenticate_request(): if self.check_setup(): provider = self.get_argument("provider", None) if provider is None: self.redirect("/setup") client = None if provider == "dropbox": client = DropboxClient() BaseController.settings["cloud_service"] = "dropbox" elif provider == "googledrive": client = GoogleDriveClient() BaseController.settings["cloud_service"] = "googledrive" else: logging.fatal("No cloud service setup.") self.write("sorry, any error occured.") return return_url = "".join([ self.request.protocol, '://', self.request.host, '/oauthcallback' ]) redirect_url = client.get_auth_url(return_url) self.redirect(redirect_url) else: self.write("setup already completed.")
def get(self): provider = BaseController.settings["cloud_service"] if provider == "dropbox": client = DropboxClient() request_token_key = self.get_argument("oauth_token") elif provider == "googledrive": client = GoogleDriveClient() request_token_key = self.get_argument("code") else: logging.fatal("No cloud service setup.") self.write("sorry, any error occured.") return result = client.save_access_token(request_token_key) if result == -1: self.write("sorry, any error occured.") return # save preference for sync utility sync_setting = {"cloud_service": provider} util.settings.save_sync_settings(sync_setting) self.redirect("/success")
def post(self): if self.authenticate_request(): if self.check_setup(): provider = self.get_argument("provider", None) if provider is None: self.redirect("/setup") client = None if provider == "dropbox": client = DropboxClient() BaseController.settings["cloud_service"] = "dropbox" elif provider == "googledrive": client = GoogleDriveClient() BaseController.settings["cloud_service"] = "googledrive" else: logging.fatal("No cloud service setup.") self.write("sorry, any error occured.") return return_url = "".join([self.request.protocol, '://', self.request.host, '/oauthcallback']) redirect_url = client.get_auth_url(return_url) self.redirect(redirect_url) else: self.write("setup already completed.")
def main(): config_file = os.path.join(os.getenv('HOME'), '.dropboxfuse') log = DropboxLogManager() client = DropboxClient(config_file) CacheManager.set_cache('MetadataCache', MetadataCache(client)) download_manager = DropboxDownloadManager(client) print download_file(download_manager, '/hello.txt') del download_manager del client del log
def main(): default_path = os.path.join(os.getenv('HOME'), '.dropboxfuse') parser = argparse.ArgumentParser() parser.add_argument('-m', '--mount-point', type=str, required=True) parser.add_argument('-c', '--config', type=str, default=default_path, required=False) parser.add_argument('-k', '--app-key', type=str, default=None, required=False) parser.add_argument('-s', '--app-secret', type=str, default=None, required=False) parser.add_argument('-a', '--access-token', type=str, default=None, required=False) options = parser.parse_args() log_manager = DropboxLogManager() dropbox_client = DropboxClient(options.config, options.app_key, options.app_secret, options.access_token) CacheManager.set_cache('MetadataCache', MetadataCache(dropbox_client)) CacheManager.set_cache('DataCache', DataCache(dropbox_client)) dropbox_fuse = DropboxFuse(dropbox_client) try: dbfuse = fuse.FUSE(dropbox_fuse, options.mount_point, foreground=True, nothreads=True, allow_other=True) except Exception as e: print str(e) raise finally: del dropbox_fuse del dropbox_client del log_manager return 0
print(f'{name} - {mk}') print("-----------------------------------------") return payment_book def notify(payment_book: PaymentBook): for payment_sheet in payment_book.sheets: cats = payment_sheet.categories for category in cats: print( f"{payment_sheet.name}:{category} - {(category.payments[0])}") if category.payments[0].payable_within_2days: pu.notify(f"{category} - {(category.payments[0])}") if __name__ == '__main__': pu = Pushover(config.pushover_apikey, config.pushover_user) dbx = DropboxClient(config.api_key) wpk = download_file() notify(wpk) getter = Ekartoteka(config.ekartoteka) getter.initialize() apartment_fee = getter.get_curret_fees_sum() print(apartment_fee) pu.notify(f'Mieszkanie: {apartment_fee:.2f}zł') wpk.update_current_payment_amount(config.ekartoteka_sheet[0], config.ekartoteka_sheet[1], apartment_fee) wpk.save_to_file(filename="Oplaty.xlsm")