def change_synchronization(account_settings): log_debug('Changing synchronization for account: %s' % (account_settings.account_name)) account_settings.synchronisation = False sync_settings_valid = False #Enable synchronization? dialog = xbmcgui.Dialog() if dialog.yesno(ADDON_NAME, LANGUAGE_STRING(30101), account_settings.account_name + '?' ) == True: account_settings.synchronisation = True log_debug('Synchronization enabled: %s' % (account_settings.synchronisation) ) if account_settings.synchronisation: #select the local folder dialog = xbmcgui.Dialog() # 3= ShowAndGetWriteableDirectory, selected_folder = dialog.browse(3, LANGUAGE_STRING(30102), 'files', mask='', treatAsFolder=True, defaultt=account_settings.syncpath) selected_folder = selected_folder.decode("utf-8") log_debug('Selected local folder: %s' % (selected_folder) ) if selected_folder != u'': account_settings.syncpath = selected_folder from resources.lib.dropboxfilebrowser import DropboxFileBrowser #select the remote folder dialog = DropboxFileBrowser("FileBrowser.xml", ADDON_PATH) client = XBMCDropBoxClient(access_token=account_settings.access_token) dialog.setDBClient(client) dialog.setHeading(LANGUAGE_STRING(30109), account_settings.remotepath) dialog.doModal() log_debug('Selected remote folder: %s' % (dialog.selectedFolder) ) if dialog.selectedFolder: account_settings.remotepath = dialog.selectedFolder #set synchronization frequency dialog = xbmcgui.Dialog() valid_freq = False while not valid_freq: #0 = ShowAndGetNumber freq_str = dialog.numeric(0, LANGUAGE_STRING(30105), str(account_settings.syncfreq) ) try: #check for a vaild freq freq = int(freq_str) except ValueError: freq = -1 if 5 <= freq <= 1440: account_settings.syncfreq = freq log_debug('Synchronization frequency set: %s' % (freq)) valid_freq = True else: log_debug('Wrong frequency value') #Wrong timeout dialog = xbmcgui.Dialog() dialog.ok(ADDON_NAME, LANGUAGE_STRING(30208)) #done sync_settings_valid = True else: sync_settings_valid = True if sync_settings_valid: account_settings.save() #Notify the DropboxSynchronizer NotifySyncClient().account_settings_changed(account_settings)
dialog = xbmcgui.Dialog() location = dialog.browse(3, LANGUAGE_STRING(30025) + LANGUAGE_STRING(30038), 'files').decode("utf-8") if location: success = True downloader = Downloader(client, path, location, isDir) downloader.start() #now wait for the FileLoader downloader.stopWhenFinished = True while downloader.isAlive(): xbmc.sleep(100) #Wait for the thread downloader.join() if downloader.canceled: log('Downloading canceled') else: log('Downloading finished') dialog = xbmcgui.Dialog() dialog.ok(ADDON_NAME, LANGUAGE_STRING(30040), location) elif action == 'sync_now': path = urllib.unquote( params['path'] ).decode("utf-8") NotifySyncClient().sync_path(account_settings, path) else: log_error('Unknown action received: %s' % (action)) else: log_error("Run as script: no account name provided!") dialog = xbmcgui.Dialog() dialog.ok(ADDON_NAME, LANGUAGE_STRING(30203)) #script So sys.argv[1] id not a handle... Don't execute the next! #xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False)