def __init__(self, config: Config): self.HOST_NAME = '0.0.0.0' self.SERVER_PORT = config.getInteger('queen_port', 4040) self.CLIENT_PORT = config.getInteger('client_port', 4041) self.KDFS_CONFIG = config self.KDFS_START_IP = config.get('nodes_start_ip', '192.168.0.0') self.KDFS_END_IP = config.get('nodes_end_ip', '192.168.5.255') self.CHUNK_SIZE = config.getInteger('chunk_size', 1024) self.MAX_TIMEOUT = config.getInteger('max_timeout', 60) # get client ip address self.CLIENT_IP = self.KDFS_CONFIG.get('client_ip', '127.0.0.1') # check if this node server is queen if config.getBoolean('is_queen', False): from server.KDFSQueen import KDFSQueen self.IS_QUEEN = True self.QUEEN = KDFSQueen(config) self.MAX_LISTEN = config.getInteger('queen_max_nodes', 1) # check for ports is already use if ServerUtils.checkPortInUse( self.CLIENT_PORT, self.CLIENT_IP) or ServerUtils.checkPortInUse( self.SERVER_PORT, self.HOST_NAME): KDFSProtocol.echo( "One of \"{}:{}\" or \"{}:{}\" ports are already use!".format( self.HOST_NAME, self.SERVER_PORT, self.CLIENT_IP, self.CLIENT_PORT), is_err=True) return # run local socket client in another thread! # self.LOCALSERVERTHREAD = threading.Thread(target=self._runLocalServer) self.LOCALSERVERTHREAD = multiprocessing.Process( target=self._runLocalServer) self.LOCALSERVERTHREAD.start() # run global socket server self._runGlobalServer()
def __init__(self, config: Config): self.GLOBAL_PORT = config.getInteger('queen_port', 4040) self.GLOBAL_CHUNK_SIZE = config.getInteger('chunk_size', 1024) start_ip = config.get('nodes_start_ip', '192.168.0.0') end_ip = config.get('nodes_end_ip', '192.168.5.255') self.GLOBAL_CONFIG = config # scan all up hosts and validate kdfs node self.scanNodes(start_ip, end_ip)
def run(self,argvs): # read kdfs config file KDFSConfig = Config(ServerUtils.CONFIG_PATH) cprint("\r\nKDFS SERVER (version {})".format(KDFSConfig.get('version','unknown')),'green',attrs=['bold']) # get kdfs server info (info,err) = MinimalCommands().identifyCommand() print("MAC Address is {} on {}({})".format(info['macaddr'],info['os'],info['arch'])) # check if server is queen if KDFSConfig.getBoolean('is_queen',False): cprint("*** THIS SERVER RUN AS QUEEN ***",'yellow') print("\n") # print(minimalUitls.searchTextByRegex("home","%.md")) # print(MinimalCommands().findCommand({'type':'rec','path':'/','mode':'name','regex':'Until'})) server = KDFSServer(KDFSConfig)
__copyright__ = "Copyright (C) 2016 Xose Pérez" __license__ = 'GPL v3' import sys from libs.Config import Config from libs.Mosquitto import Mosquitto from libs.Manager import Manager from libs.services.TheThingsIO import TheThingsIO if __name__ == "__main__": config = Config('config/mqtt2thethingsio.yaml') manager = Manager(config.get('daemon', 'pidfile', '/tmp/mqtt2cloud.pid')) manager.stdout = config.get('daemon', 'stdout', '/dev/null') manager.stderr = config.get('daemon', 'stderr', '/dev/null') manager.debug = config.get('daemon', 'debug', False) mqtt = Mosquitto(config.get('mqtt', 'client_id')) mqtt.host = config.get('mqtt', 'host') mqtt.port = config.get('mqtt', 'port') mqtt.keepalive = config.get('mqtt', 'keepalive') mqtt.clean_session = config.get('mqtt', 'clean_session') mqtt.qos = config.get('mqtt', 'qos', 0) mqtt.retain = config.get('mqtt', 'retain', True) mqtt.status_topic = config.get('mqtt', 'status_topic') mqtt.set_will = config.get('mqtt', 'set_will') manager.mqtt = mqtt
__copyright__ = "Copyright (C) 2013 Xose Pérez" __license__ = 'GPL v3' import sys from libs.Config import Config from libs.Mosquitto import Mosquitto from libs.Manager import Manager from libs.services.Sense import Sense if __name__ == "__main__": config = Config('config/mqtt2sense.yaml') manager = Manager(config.get('daemon', 'pidfile', '/tmp/mqtt2sense.pid')) manager.stdout = config.get('daemon', 'stdout', '/dev/null') manager.stderr = config.get('daemon', 'stderr', '/dev/null') manager.debug = config.get('daemon', 'debug', False) mqtt = Mosquitto(config.get('mqtt', 'client_id')) mqtt.host = config.get('mqtt', 'host') mqtt.port = config.get('mqtt', 'port') mqtt.keepalive = config.get('mqtt', 'keepalive') mqtt.clean_session = config.get('mqtt', 'clean_session') mqtt.qos = config.get('mqtt', 'qos', 0) mqtt.retain = config.get('mqtt', 'retain', True) mqtt.status_topic = config.get('mqtt', 'status_topic') mqtt.set_will = config.get('mqtt', 'set_will') manager.mqtt = mqtt
def initForm(self): # 1st tab labels self.ui.lblResultsDisplayed.setText(u"Displayed results: 0/0") self.ui.lblTrackedShows.setText(u"Tracked shows: 0") # Format Sample fmtSample = u"<u><b>Sample:</b></u> <b>show:</b> %s, <b>title:</b> %s, <b>season</b>: %d, <b>episode</b>: %d" % ( Globals().sampleEpisode['show'], Globals().sampleEpisode['title'], Globals().sampleEpisode['season'], Globals().sampleEpisode['episode']) self.ui.lblFormatSample.setText(fmtSample) #### Versions version = Globals().versions # nextShows Footer Release labelContent = str(self.ui.lblFooterRelease.text()) self.ui.lblFooterRelease.setText(labelContent % version['nextShows']) # nextShows Release (About tab) labelContent = str(self.ui.lblNextShowsVersion.text()) self.ui.lblNextShowsVersion.setText(labelContent % version['nextShows']) # Libs releases (About tab) # Python version a, b, c, d, e = sys.version_info pythonVersion = "%d.%d.%d" % (a, b, c) # labelContent = str(self.ui.lblLibsVersion.text()) self.ui.lblLibsVersion.setText( labelContent % (pythonVersion, QT_VERSION_STR, PYQT_VERSION_STR, version["KDE"])) #### Default values self.ui.spinNumPastDays.setMinimum(0) self.ui.spinNumPastDays.setMaximum(99) #self.ui.spinNumPastDays.setValue(1) self.ui.spinFixedDispLines.setMinimum(1) self.ui.spinFixedDispLines.setMaximum(50) #self.ui.spinFixedDispLines.setValue(10) self.ui.spinMinDispLines.setMinimum(1) self.ui.spinMinDispLines.setMaximum(49) #self.ui.spinMinDispLines.setValue(1) self.ui.spinMaxDispLines.setMinimum(2) self.ui.spinMaxDispLines.setMaximum(50) #self.ui.spinMaxDispLines.setValue(10) # self.ui.spinColorsSingleDay.setMinimum(-99) self.ui.spinColorsSingleDay.setMaximum(99) self.ui.spinColorsSingleDay.setValue(0) self.ui.spinColorsFrom.setMinimum(-99) self.ui.spinColorsFrom.setMaximum(98) self.ui.spinColorsFrom.setValue(0) self.ui.spinColorsTo.setMinimum(-98) self.ui.spinColorsTo.setMaximum(99) self.ui.spinColorsTo.setValue(10) # default color for "Select color" self.ui.lblSelectColor.setPixmap( self.drawPreviewColor(self.lastColorUsed, 36, 36)) # Theme combo self.ui.comboTheme.addItems(Globals().availableThemes) #### #### Read config #### tools.msgDebug(u"Reading config...", __name__) config = Config() # Enable/Disable DEBUG if config.getboolean("main", "debug") == False: tools.msgDebug("Disabling debug messages !", __name__) Globals.DEBUG = False # Get Data self.myShows = config.getShows() self.displayMyShows() self.myColors = config.getColors() self.ui.lblDefaultColor.setPixmap( self.drawPreviewColor(self.myColors['default'], 36, 36)) self.displayMyColors() if config.get("display", "type") == "Fixed": self.ui.radioDispFixedLines.setChecked(True) else: self.ui.radioDispAutoResize.setChecked(True) self.ui.spinNumPastDays.setValue( int(config.get("display", "past_days"))) self.ui.spinFixedDispLines.setValue( int(config.get("display", "lines_fixed"))) self.ui.spinMinDispLines.setValue( int(config.get("display", "lines_min"))) self.ui.spinMaxDispLines.setValue( int(config.get("display", "lines_max"))) self.ui.leditFormat.setText(config.get("display", "format")) self.refreshFormatPreview(str(self.ui.leditFormat.text())) self.ui.spinCacheExpiration.setValue( int(config.get("misc", "cache_expiration"))) self.ui.leditBrowser.setText(config.get("misc", "browser")) # Fallback code since the "theme" key was located in the [display] section # in versions < 2.1.0 try: idx = int(Globals().availableThemes.index( config.get("misc", "theme"))) except: idx = 0 self.ui.comboTheme.setCurrentIndex(idx) # Date Separator # Fallback code since the "date_separator" key doesn't exist in version < 2.1.0 try: sep = config.get("display", "date_separator") except: sep = "/" self.ui.leditDateSeparator.setText(sep) # Date Format dateFormat = config.get("display", "date_format") data = ["%" + a for a in dateFormat.split(sep)] idx = self.ui.comboDateFormat.findData(QVariant(data)) if idx == -1: idx = 0 self.ui.comboDateFormat.setCurrentIndex(idx) config.close() # Reset "Save" button state self.saveRequired(False) tools.msgDebug(u"Done!", __name__)
class MinimalCommands: def __init__(self): # get kdfs config self.config = Config(ServerUtils.CONFIG_PATH) self.storage_path = self.config.get('storage', './') # ------------------------------------------------ def _getAbsPath(self, pathi: str): return os.path.abspath("{}/{}".format(self.storage_path, pathi)) # ------------------------------------------------ def listCommand(self, params: dict): response = [] # create absolute path with storage path absPath = self._getAbsPath(params['path']) # check for exist directory if not os.path.exists(absPath) or not os.path.isdir(absPath): return ('', "no such directory to retrive") # get list of files and dirs files = os.listdir(absPath) # iterate all files for filei in files: newPath = os.path.join(absPath, filei) sizei = os.stat(newPath).st_size # translate size humanly size = minimalUitls.convertBytesToHumanly(sizei) # append to response response.append({ 'name': filei, 'size': size, 'type': 'dir' if os.path.isdir(newPath) else 'file', 'path': os.path.join(params['path'], filei) }) return (response, '') # ------------------------------------------------ def findCommand(self, params: dict): response = [] # print("minimal:",params) # create absolute path with storage path absPath = self._getAbsPath(params['path']) # check for exist directory if not os.path.exists(absPath) or not os.path.isdir(absPath): return ('', "no such directory to retrive") # get list of files and dirs (can recursion) files = minimalUitls.getAllFilesList( absPath, is_recursion=(params['type'] == 'rec'), just_files=(params['type'] == 'file')) # get max items maxItems = self.config.getInteger('list_limit', 10) # print('final files:',files) # iterate all files for filei in files: # print('file to find:',filei) # get abs path newPath = os.path.join(absPath, filei) findCount = 0 # if search in filename if params['mode'] == 'name': # search regex on filename findCount = len( minimalUitls.searchTextByRegex(filei, params['regex'])) elif params['mode'] == 'content': # check if directory if os.path.isdir(newPath): continue # check if file is binary if minimalUitls.checkIsBinaryFile(newPath): continue # open file and read line by line try: with open(newPath, 'r', encoding='utf-8') as f: for line in f: # search regex on every line findCount += len( minimalUitls.searchTextByRegex( line, params['regex'])) except: pass # append to response if findCount > 0 and len(response) <= maxItems: response.append({ 'name': filei, 'count': findCount, 'type': 'dir' if os.path.isdir(newPath) else 'file', 'path': os.path.join(params['path'], filei) }) # print('response_minimal:',params,response) return (response, '') # ------------------------------------------------ def existCommand(self, params: dict): # create absolute path with storage path absPath = self._getAbsPath(params['path']) # check for exist path if os.path.exists(absPath): return ("true", '') else: return ('false', '') # ------------------------------------------------ def statCommand(self, params: dict): response = {} # create absolute path with storage path absPath = self._getAbsPath(params['path']) # check for exist directory or file if not os.path.exists(absPath): return ('', "no such file or directory to retrive") # get stat of absolute path (mode, ino, dev, nlink, uid, gid, sizei, atime, mtime, ctime) = os.stat(absPath) # fileStat = os.stat(newPath) # translate size humanly size = minimalUitls.convertBytesToHumanly(sizei) # append to response response = { 'name': os.path.basename(absPath), 'size': size, 'type': 'dir' if os.path.isdir(absPath) else 'file', 'kdfs_path': params['path'], 'local_path': absPath, 'last_access': time.ctime(atime), 'last_modify': time.ctime(mtime), 'owner': pwd.getpwuid(uid).pw_name } return (response, '') # ------------------------------------------------ def identifyCommand(self, params: dict = {}): res: dict = { 'macaddr': ServerUtils.getMacAddress(), 'version': self.config.getInteger('version', 0), 'os': platform.system(), 'arch': platform.machine(), 'hostname': platform.node(), 'node_type': 'queen' if self.config.getBoolean('is_queen', False) else 'node' } return (res, '') # ------------------------------------------------ def upgradeCommand(self, params: dict): # if packet number is 1,then just return 'yes' or 'no' if params['packnumber'] == 1: # check if server can accept upgrades or not if self.config.getBoolean('accept_upgrades', True): KDFSProtocol.echo( "Accept kdfs version {} upgrading...".format( params['version']), 'upgrade') # check if upgrades folder is not exsit if not os.path.exists(ServerUtils.UPGRADE_PATH): os.makedirs(ServerUtils.UPGRADE_PATH) # resturn accept response return ('yes', '') else: KDFSProtocol.echo("Refuse any upgrading", 'upgrade') # return refuse response return ('no', '') # if get file in next packet number, save it else: try: # save to file with open(ServerUtils.UPGRADE_ZIP_PATH.format( params['version']), mode='wb') as f: f.write(bytearray(params['data'])) # extract to min source with tarfile.open( ServerUtils.UPGRADE_ZIP_PATH.format(params['version']), 'r:gz') as kdfsTar: kdfsTar.extractall("./") # update kdfs version number self.config.updateItem('version', params['version']) KDFSProtocol.echo( "saved kdfs version {} upgraded file in local".format( params['version']), 'upgrade') # if os is linux, then run bash script if ServerUtils.detectOS() == 'linux': os.system("sh ./upgrade.sh &") else: pass # TODO: return ('success', '') except Exception as e: return (e, '') # ------------------------------------------------ def notifyCommand(self, params: dict): response = Notification(self.config.get('app_name', 'KDFS'), params['text'], 30).send() if response: return ('success', '') else: return ('failed', '') # ------------------------------------------------ def copyCommand(self, params: dict): # create absolute path with storage path absPath = self._getAbsPath(params['path']) # print('abspath:',absPath) # if type of copy is 'src' if params['mode'] == 'src': # check for exist directory or file if not os.path.exists(absPath): return ('', "no such file or directory to retrive") # if path is for file if os.path.isfile(absPath): content = KDFSProtocol.fileCompress(absPath) return (content, '') # if path is for directory elif os.path.isdir(absPath): content = KDFSProtocol.directoryCompress(absPath) return (content, '') else: return ('', "undefined path") # if type of copy is 'dest' elif params['mode'] == 'dest': if params['packnumber'] == 1: # check for exist parent directory of dest path if not os.path.exists(os.path.dirname(absPath)): return ('', "no such parent directory to retrive") return ('success', '') else: # print("data file (copy):",params['data']) # save to file filename = KDFSProtocol.saveTempCompressedFile(params['data']) # extract to min source with tarfile.open(filename, 'r:gz') as kdfsTar: kdfsTar.extractall(absPath) return ('success', '')
# get items list of response for key in response: itemsList.append([key,response[key]]) # print(val,end=lastSpaces) # print() print(tabulate(itemsList, tablefmt='presto')) # ------------------------------------------------ currentMilliseconds = lambda: int(round(time.time() * 1000)) # ------------------------------------------------ # when start kdfs client program if __name__ == "__main__": # read kdfs config file KDFSConfig = Config(ServerUtils.CONFIG_PATH) # KDFSConfig.read("kdfs.conf") cprint("KDFS CLIENT shell (version {})".format(KDFSConfig.get('version','unknown')),'blue',attrs=['bold']) print("Using \"help\" for more information.") print("\n") # if not found any command if len(sys.argv) <= 1: help() exit(0) # get user command command = sys.argv[1] params = sys.argv[2:] # print('argvs:',command,params) # check for arguments if command == 'help': help() else: # start time of process command
def initWidget(widget): global g_nextCacheRefresh, g_showList, g_showIds, g_cacheExpiration, g_pastDays, g_linesMin, g_linesMax # Pass the widget reference Applet.widget = widget # Init splash splash = Applet().Splash() splash.show() # Create dir structure splash.setText("Checking config dirs...") createConfigDirs() # Read config splash.setText("Reading config...") config = Config() # Check whether we want DEBUG messages enabled or not if config.getboolean("main", "debug") == False: tools.msgDebug("Disabling debug messages !", __name__) Globals.DEBUG = False # Copy GUI files (if necessary) if Globals().versions['nextShows'] != config.get("main", "version") \ or not "launchGUI" in os.listdir( Globals().nsCGuiBaseDir ): # Init dir structures and copy files splash.setText("Setup GUI...") copyThemeFilesToConfigDir(widget) config.set("main", "version", Globals().versions['nextShows']) # Get other useful infos from config splash.setText("Reading config...") displayType = config.get("display", "type") if displayType == "Fixed": g_linesMax = config.getint("display", "lines_fixed") g_linesMin = g_linesMax else: g_linesMin = config.getint("display", "lines_min") g_linesMax = config.getint("display", "lines_max") g_cacheExpiration = config.getint("misc", "cache_expiration") g_pastDays = config.getint("display", "past_days") applet.colorList = config.getColors() applet.episodeFormatString = config.get( "display", "format") applet.browser = config.get( "misc", "browser") applet.dateFormat = config.get( "display", "date_format") applet.whenFormat = config.getint("misc", "when_format") # Getting the show list splash.setText("Getting show list....") g_showList = config.getShows() # Extract IDs g_showIds = [ show['id'] for show in g_showList ] # Init cache cache.setExpiration( g_cacheExpiration ) cache.showIds = g_showIds # Refresh cache if necessary staledList = cache.getStaledCacheFiles() for id in staledList: for show in g_showList: if show['id'] == id: showName = show['name'] splash.setText("Updating cache: '%s'..." % showName) cache.cacheEpisodeList( id ) # Fetch data to display splash.setText("Filtering episodes...") data = Data() episodeList = data.getEpisodeList( g_showIds, g_pastDays, g_linesMax ) applet.episodeList = episodeList # Close the splash splash.setText("Done!") splash.hide() # Init widget # Fallback (for compatibility reasons) # "[display] theme=" was moved to "[misc] theme=" try: applet.themeName = config.get("misc", "theme") except: applet.themeName = Globals().defaultThemeName numReturnedEpisode = len( episodeList ) if numReturnedEpisode < g_linesMin: themeLines = g_linesMin elif numReturnedEpisode > g_linesMax: themeLines = g_linesMax else: themeLines = numReturnedEpisode applet.themeLines = themeLines applet.drawBackground() applet.printEpisodeList() # Store next cache refresh g_nextCacheRefresh = cache.getNextRefreshTS() # Setup menu entry for config GUI karamba.addMenuConfigOption(widget, "config_gui", "Configure...") karamba.setMenuConfigOption(widget, "config_gui", 0)
Entry point, initiates components and loops forever... """ self.log("[INFO] Starting " + __app__ + " v" + __version__) self.mqtt_connect() self.prepare() while True: self.mqtt.loop() if time.time() > self.next_event_time: self.push_message() if __name__ == "__main__": config = Config('rentalito.yaml') manager = Rentalito(config.get('general', 'pidfile', '/tmp/rentalito.pid')) manager.stdout = config.get('general', 'stdout', '/dev/null') manager.stderr = config.get('general', 'stderr', '/dev/null') manager.debug = config.get('general', 'debug', False) manager.publish_to = config.get('general', 'publish_to', '/client/rentalito') manager.minimum_time = config.get('general', 'minimum_time', 5) manager.time_length_ratio = config.get('general', 'time_length_ratio', 0.5) manager.topics = config.get('topics', None, {}); mqtt = Mosquitto(config.get('mqtt', 'client_id')) mqtt.host = config.get('mqtt', 'host') mqtt.port = config.get('mqtt', 'port') mqtt.keepalive = config.get('mqtt', 'keepalive') mqtt.clean_session = config.get('mqtt', 'clean_session') mqtt.qos = config.get('mqtt', 'qos') mqtt.retain = config.get('mqtt', 'retain')
def initWidget(widget): global g_nextCacheRefresh, g_showList, g_showIds, g_cacheExpiration, g_pastDays, g_linesMin, g_linesMax # Pass the widget reference Applet.widget = widget # Init splash splash = Applet().Splash() splash.show() # Create dir structure splash.setText("Checking config dirs...") createConfigDirs() # Read config splash.setText("Reading config...") config = Config() # Check whether we want DEBUG messages enabled or not if config.getboolean("main", "debug") == False: tools.msgDebug("Disabling debug messages !", __name__) Globals.DEBUG = False # Copy GUI files (if necessary) if Globals().versions['nextShows'] != config.get("main", "version") \ or not "launchGUI" in os.listdir( Globals().nsCGuiBaseDir ): # Init dir structures and copy files splash.setText("Setup GUI...") copyThemeFilesToConfigDir(widget) config.set("main", "version", Globals().versions['nextShows']) # Get other useful infos from config splash.setText("Reading config...") displayType = config.get("display", "type") if displayType == "Fixed": g_linesMax = config.getint("display", "lines_fixed") g_linesMin = g_linesMax else: g_linesMin = config.getint("display", "lines_min") g_linesMax = config.getint("display", "lines_max") g_cacheExpiration = config.getint("misc", "cache_expiration") g_pastDays = config.getint("display", "past_days") applet.colorList = config.getColors() applet.episodeFormatString = config.get("display", "format") applet.browser = config.get("misc", "browser") applet.dateFormat = config.get("display", "date_format") applet.whenFormat = config.getint("misc", "when_format") # Getting the show list splash.setText("Getting show list....") g_showList = config.getShows() # Extract IDs g_showIds = [show['id'] for show in g_showList] # Init cache cache.setExpiration(g_cacheExpiration) cache.showIds = g_showIds # Refresh cache if necessary staledList = cache.getStaledCacheFiles() for id in staledList: for show in g_showList: if show['id'] == id: showName = show['name'] splash.setText("Updating cache: '%s'..." % showName) cache.cacheEpisodeList(id) # Fetch data to display splash.setText("Filtering episodes...") data = Data() episodeList = data.getEpisodeList(g_showIds, g_pastDays, g_linesMax) applet.episodeList = episodeList # Close the splash splash.setText("Done!") splash.hide() # Init widget # Fallback (for compatibility reasons) # "[display] theme=" was moved to "[misc] theme=" try: applet.themeName = config.get("misc", "theme") except: applet.themeName = Globals().defaultThemeName numReturnedEpisode = len(episodeList) if numReturnedEpisode < g_linesMin: themeLines = g_linesMin elif numReturnedEpisode > g_linesMax: themeLines = g_linesMax else: themeLines = numReturnedEpisode applet.themeLines = themeLines applet.drawBackground() applet.printEpisodeList() # Store next cache refresh g_nextCacheRefresh = cache.getNextRefreshTS() # Setup menu entry for config GUI karamba.addMenuConfigOption(widget, "config_gui", "Configure...") karamba.setMenuConfigOption(widget, "config_gui", 0)
def initForm(self): # 1st tab labels self.ui.lblResultsDisplayed.setText( u"Displayed results: 0/0" ) self.ui.lblTrackedShows.setText( u"Tracked shows: 0" ) # Format Sample fmtSample = u"<u><b>Sample:</b></u> <b>show:</b> %s, <b>title:</b> %s, <b>season</b>: %d, <b>episode</b>: %d" % ( Globals().sampleEpisode['show'], Globals().sampleEpisode['title'], Globals().sampleEpisode['season'], Globals().sampleEpisode['episode'] ) self.ui.lblFormatSample.setText( fmtSample ) #### Versions version = Globals().versions # nextShows Footer Release labelContent=str(self.ui.lblFooterRelease.text()) self.ui.lblFooterRelease.setText(labelContent % version['nextShows']) # nextShows Release (About tab) labelContent=str(self.ui.lblNextShowsVersion.text()) self.ui.lblNextShowsVersion.setText(labelContent % version['nextShows']) # Libs releases (About tab) # Python version a,b,c,d,e = sys.version_info pythonVersion = "%d.%d.%d" % (a, b, c) # labelContent=str(self.ui.lblLibsVersion.text()) self.ui.lblLibsVersion.setText(labelContent % ( pythonVersion, QT_VERSION_STR, PYQT_VERSION_STR, version["KDE"]) ) #### Default values self.ui.spinNumPastDays.setMinimum(0) self.ui.spinNumPastDays.setMaximum(99) #self.ui.spinNumPastDays.setValue(1) self.ui.spinFixedDispLines.setMinimum(1) self.ui.spinFixedDispLines.setMaximum(50) #self.ui.spinFixedDispLines.setValue(10) self.ui.spinMinDispLines.setMinimum(1) self.ui.spinMinDispLines.setMaximum(49) #self.ui.spinMinDispLines.setValue(1) self.ui.spinMaxDispLines.setMinimum(2) self.ui.spinMaxDispLines.setMaximum(50) #self.ui.spinMaxDispLines.setValue(10) # self.ui.spinColorsSingleDay.setMinimum(-99) self.ui.spinColorsSingleDay.setMaximum(99) self.ui.spinColorsSingleDay.setValue(0) self.ui.spinColorsFrom.setMinimum(-99) self.ui.spinColorsFrom.setMaximum(98) self.ui.spinColorsFrom.setValue(0) self.ui.spinColorsTo.setMinimum(-98) self.ui.spinColorsTo.setMaximum(99) self.ui.spinColorsTo.setValue(10) # default color for "Select color" self.ui.lblSelectColor.setPixmap( self.drawPreviewColor( self.lastColorUsed, 36, 36 ) ) # Theme combo self.ui.comboTheme.addItems( Globals().availableThemes ) #### #### Read config #### tools.msgDebug(u"Reading config...", __name__) config = Config() # Enable/Disable DEBUG if config.getboolean("main", "debug") == False: tools.msgDebug("Disabling debug messages !", __name__) Globals.DEBUG = False # Get Data self.myShows = config.getShows() self.displayMyShows() self.myColors = config.getColors() self.ui.lblDefaultColor.setPixmap( self.drawPreviewColor( self.myColors['default'], 36, 36 ) ) self.displayMyColors() if config.get("display", "type") == "Fixed": self.ui.radioDispFixedLines.setChecked( True ) else: self.ui.radioDispAutoResize.setChecked( True ) self.ui.spinNumPastDays.setValue( int( config.get( "display", "past_days" ) ) ) self.ui.spinFixedDispLines.setValue( int( config.get( "display", "lines_fixed" ) ) ) self.ui.spinMinDispLines.setValue( int( config.get( "display", "lines_min" ) ) ) self.ui.spinMaxDispLines.setValue( int( config.get( "display", "lines_max" ) ) ) self.ui.leditFormat.setText( config.get( "display", "format" ) ) self.refreshFormatPreview( str(self.ui.leditFormat.text()) ) self.ui.spinCacheExpiration.setValue( int( config.get( "misc", "cache_expiration" ) ) ) self.ui.leditBrowser.setText( config.get( "misc", "browser" ) ) # Fallback code since the "theme" key was located in the [display] section # in versions < 2.1.0 try: idx = int( Globals().availableThemes.index( config.get( "misc", "theme" ) ) ) except: idx = 0 self.ui.comboTheme.setCurrentIndex( idx ) # Date Separator # Fallback code since the "date_separator" key doesn't exist in version < 2.1.0 try: sep = config.get( "display", "date_separator" ) except: sep = "/" self.ui.leditDateSeparator.setText( sep ) # Date Format dateFormat = config.get( "display", "date_format" ) data = [ "%"+a for a in dateFormat.split( sep ) ] idx = self.ui.comboDateFormat.findData( QVariant( data ) ) if idx==-1: idx = 0 self.ui.comboDateFormat.setCurrentIndex( idx ) config.close() # Reset "Save" button state self.saveRequired(False) tools.msgDebug(u"Done!", __name__)