Beispiel #1
0
    def refresh_action(self):
        """ This will be called by the panel manager (not you!) whenever
        this panel becomes visible. The goal of this mode
        is to draw the panel, display its data.

        This method should be reimplemented in child class.

        *** NEVER CALL THIS DIRECTLY, use refresh_panel instead ***
        """

        mainlog.warning( "HorsePanel.refresh_action() : Not implemented !")
Beispiel #2
0
def upgrade_file(path):
    global configuration
    re_file = re.compile(r'koi-delivery_slips-([0-9]+\.[0-9]+\.[0-9]+)\.zip')
    exe_filename = "{}/{}.exe".format(configuration.get("Globals", "codename"),
                                      configuration.get("Globals", "codename"))

    if os.path.exists(path):
        match = re_file.match(os.path.basename(path))

        if match:
            version = match.groups()[0]

            candidates = []
            exe_correct = False
            with zipfile.ZipFile(path, 'r') as zin:
                for item in zin.infolist():
                    if item.filename == exe_filename:
                        exe_correct = True
                        break
                    elif ".exe" in item.filename:
                        candidates.append(item.filename)

            if exe_correct:
                configuration.set("DownloadSite", "current_version",
                                  str(version))
                configuration.set("DownloadSite", "client_path", path)
                configuration.save()
                mainlog.info(
                    "Configuration successfully updated with delivery_slips version {}."
                    .format(version))
                mainlog.warning(
                    "Don't forget to restart the server to take it into account !"
                )
                return True
            else:
                mainlog.error(
                    "Didn't find {} inside the file you've given. Possible candidates {}"
                    .format(exe_filename, ", ".join(candidates)))
        else:
            mainlog.error(
                "I don't recognize the filename. It should be 'koi-delivery_slips-a.b.c.zip'."
            )
    else:
        mainlog.error("The file {} was not found.".format(path))

    return False
Beispiel #3
0
 def get(self, section, tag):
     # Pay attention ! If the key is not found in the configuration, configobj will
     # look at the default value in the spec.
     if section in self.base_configuration and tag in self.base_configuration[
             section] and self.base_configuration[section][tag]:
         # mainlog.debug(u"Found tag {}/{} in config file -> {}".format(section,tag,self.base_configuration[section][tag]))
         return self.base_configuration[section][tag]
     else:
         mainlog.warning(
             "Could not find tag {}/{} in config file (or it has dubious empty value). Trying embedded config file."
             .format(section, tag))
         if self.backup_configuration and section in self.backup_configuration and tag in self.backup_configuration[
                 section]:
             return self.backup_configuration[section][tag]
         else:
             mainlog.error(
                 "Could not find tag {}/{} in config file nor in embedded config file. Defaulting to None"
                 .format(section, tag))
             return None
Beispiel #4
0
    def preselect(self, fq_id: int, emit_selection_signal: bool = True):
        if not self._filters:
            self.reload()

        for i in range(len(self._filters)):
            if self._filters[i].filter_query_id == fq_id:
                self.setCurrentIndex(i)
                if emit_selection_signal:
                    self.filter_query_selected.emit(self._filters[i])
                return

        # If the filter has been removed, then the configuration file
        # is not correct anymore. I could warn the user, but the problem
        # is that if I do it from here, then the warning might be
        # out of context (gui wise). So I prefer to fail silently.

        mainlog.warning("Unable to preselect filter id {}".format(fq_id))
        if self._filters:
            self.setCurrentIndex(0)
            if emit_selection_signal:
                self.filter_query_selected.emit(self._filters[0])