def start_services(self): """Start the background services""" self.dial_srv_instance.server_activate() self.dial_srv_thread.start() LOG.info('[DialServer] service started') self.ssdp_udp_srv_thread.start() LOG.info('[SSDPUDPServer] service started')
def install(pathitems, params): LOG.info('Start install Kodi "{}" (params "{}")', pathitems[-1], params) use_task_scheduler = G.ADDON.getSettingBool('usetaskscheduler') save_downloads = G.ADDON.getSettingBool('save_downloads') # Download the file if not kodi_ops.dlg_confirm( kodi_ops.get_local_string(30070), kodi_ops.get_local_string(30071).format(pathitems[-1])): return # Check if the task is installed if use_task_scheduler and not misc.check_task(): kodi_ops.dlg_ok(kodi_ops.get_local_string(30070), kodi_ops.get_local_string(30072)) return # Check if destination path exist if not folder_exists(G.INSTALLER_TEMP_PATH): create_folder(G.INSTALLER_TEMP_PATH) # Check if the setup installer is already downloaded dwn_filepath = join_folders_paths(G.DOWNLOADS_PATH, '/'.join(pathitems[:-1]), pathitems[-1]) # Temp file path will be used by the Windows Task scheduled temp_filepath = join_folders_paths(G.INSTALLER_TEMP_PATH, G.INSTALLER_TEMP_NAME) if params.get('is_local', 'False') == 'True': # Get the file to install from "downloads" folder if not file_exists(dwn_filepath): raise FileExistsError('The file {] not exists'.format( pathitems[:-1])) copy_file(dwn_filepath, temp_filepath) else: # Download the file if save_downloads and file_exists(dwn_filepath): # Copy the existing file to the temp file path copy_file(dwn_filepath, temp_filepath) else: # Download the setup installer file url_file_path = '/'.join(pathitems) if not download_file(G.MIRROR_BASE_URL + url_file_path, temp_filepath, pathitems[-1]): # Download cancelled kodi_ops.show_notification(kodi_ops.get_local_string(30073)) return # Save the setup installer file if save_downloads: copy_file(temp_filepath, dwn_filepath) with kodi_ops.show_busy_dialog(): # Run the "AutoUpdateWorker" bash script _run_auto_update_worker(use_task=use_task_scheduler) # Wait a bit before close Kodi, # the bash script have to read the executable path from the Kodi process before continue time.sleep(2) kodi_ops.json_rpc('Application.Quit')
def shutdown(self): """Stop the background services""" self.dial_srv_instance.shutdown() self.dial_srv_instance.server_close() self.dial_srv_instance = None self.dial_srv_thread.join() self.dial_srv_thread = None LOG.info('[DialServer] service stopped') self.ssdp_udp_srv_instance.shutdown() self.ssdp_udp_srv_instance.server_close() self.ssdp_udp_srv_instance = None self.ssdp_udp_srv_thread.join() self.ssdp_udp_srv_thread = None LOG.info('[SSDPUPDServer] service stopped')
def run(argv): # Initialize globals right away to avoid stale values from the last addon invocation. # Otherwise Kodi's reuseLanguageInvoker will cause some really quirky behavior! # PR: https://github.com/xbmc/xbmc/pull/13814 G.init_globals(argv) LOG.info('Started (Version {})'.format(G.VERSION_RAW)) LOG.info('URL is {}'.format(G.URL)) success = False try: pathitems = [part for part in G.REQUEST_PATH.split('/') if part] success = route(pathitems) except Exception as exc: import traceback LOG.error(traceback.format_exc()) kodi_ops.dlg_ok( 'AutoUpdateKodi', kodi_ops.get_local_string(30700).format('[{}] {}'.format( exc.__class__.__name__, exc))) if not success: from xbmcplugin import endOfDirectory endOfDirectory(handle=G.PLUGIN_HANDLE, succeeded=False) LOG.log_time_trace()