From: Michael Tremer Date: Fri, 23 Dec 2011 20:10:08 +0000 (+0100) Subject: Add "pakfire-server info" command. X-Git-Tag: 0.9.20~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aad6f600c1bdf5e4d90a7265959b2780d76d339a;p=pakfire.git Add "pakfire-server info" command. This command dumps some information about the hardware pakfire is running on. --- diff --git a/po/pakfire.pot b/po/pakfire.pot index e616fa5ee..4c40ffa57 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-12-16 16:00+0100\n" +"POT-Creation-Date: 2011-12-23 21:08+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -381,7 +381,7 @@ msgstr "" msgid "You cannot run pakfire-builder in a pakfire chroot." msgstr "" -#: ../python/pakfire/cli.py:379 ../python/pakfire/cli.py:676 +#: ../python/pakfire/cli.py:379 ../python/pakfire/cli.py:688 msgid "Pakfire builder command line interface." msgstr "" @@ -389,25 +389,25 @@ msgstr "" msgid "Update the package indexes." msgstr "" -#: ../python/pakfire/cli.py:443 ../python/pakfire/cli.py:696 +#: ../python/pakfire/cli.py:443 ../python/pakfire/cli.py:708 msgid "Build one or more packages." msgstr "" -#: ../python/pakfire/cli.py:445 ../python/pakfire/cli.py:698 +#: ../python/pakfire/cli.py:445 ../python/pakfire/cli.py:710 msgid "Give name of at least one package to build." msgstr "" -#: ../python/pakfire/cli.py:449 ../python/pakfire/cli.py:702 +#: ../python/pakfire/cli.py:449 ../python/pakfire/cli.py:714 msgid "Build the package for the given architecture." msgstr "" #: ../python/pakfire/cli.py:451 ../python/pakfire/cli.py:479 -#: ../python/pakfire/cli.py:704 +#: ../python/pakfire/cli.py:716 msgid "Path were the output files should be copied to." msgstr "" #: ../python/pakfire/cli.py:453 ../python/pakfire/cli.py:468 -#: ../python/pakfire/cli.py:706 +#: ../python/pakfire/cli.py:718 msgid "Mode to run in. Is either 'release' or 'development' (default)." msgstr "" @@ -461,35 +461,39 @@ msgstr "" msgid "Pakfire server command line interface." msgstr "" -#: ../python/pakfire/cli.py:626 +#: ../python/pakfire/cli.py:628 msgid "Request a build job from the server." msgstr "" -#: ../python/pakfire/cli.py:632 +#: ../python/pakfire/cli.py:634 msgid "Send a keepalive to the server." msgstr "" -#: ../python/pakfire/cli.py:639 +#: ../python/pakfire/cli.py:641 msgid "Update all repositories." msgstr "" -#: ../python/pakfire/cli.py:645 +#: ../python/pakfire/cli.py:647 msgid "Repository management commands." msgstr "" -#: ../python/pakfire/cli.py:653 +#: ../python/pakfire/cli.py:655 msgid "Create a new repository index." msgstr "" -#: ../python/pakfire/cli.py:654 +#: ../python/pakfire/cli.py:656 msgid "Path to the packages." msgstr "" -#: ../python/pakfire/cli.py:655 +#: ../python/pakfire/cli.py:657 msgid "Path to input packages." msgstr "" -#: ../python/pakfire/cli.py:708 +#: ../python/pakfire/cli.py:662 +msgid "Dump some information about this machine." +msgstr "" + +#: ../python/pakfire/cli.py:720 msgid "Do not verify build dependencies." msgstr "" @@ -705,13 +709,13 @@ msgid "%s: package database" msgstr "" #. Create progress bar. -#: ../python/pakfire/repository/index.py:394 +#: ../python/pakfire/repository/index.py:395 #, python-format msgid "Loading from %s" msgstr "" #. Add all packages from the database to the index. -#: ../python/pakfire/repository/index.py:457 +#: ../python/pakfire/repository/index.py:458 msgid "Loading installed packages" msgstr "" @@ -755,6 +759,35 @@ msgstr "" msgid " Solutions:" msgstr "" +#: ../python/pakfire/server.py:267 +msgid "Could not be determined" +msgstr "" + +#: ../python/pakfire/server.py:291 +msgid "Hostname" +msgstr "" + +#. Hardware information +#: ../python/pakfire/server.py:295 +msgid "Hardware information" +msgstr "" + +#: ../python/pakfire/server.py:296 +msgid "CPU model" +msgstr "" + +#: ../python/pakfire/server.py:297 +msgid "Memory" +msgstr "" + +#: ../python/pakfire/server.py:299 +msgid "Native arch" +msgstr "" + +#: ../python/pakfire/server.py:301 +msgid "Supported arches" +msgstr "" + #: ../python/pakfire/transaction.py:91 #, python-format msgid "file %s from %s conflicts with file from package %s" diff --git a/python/pakfire/cli.py b/python/pakfire/cli.py index 7b82215e8..3e13dbc04 100644 --- a/python/pakfire/cli.py +++ b/python/pakfire/cli.py @@ -598,6 +598,7 @@ class CliServer(Cli): self.parse_command_keepalive() self.parse_command_repoupdate() self.parse_command_repo() + self.parse_command_info() # Finally parse all arguments from the command line and save them. self.args = self.parser.parse_args() @@ -606,6 +607,7 @@ class CliServer(Cli): self.action2func = { "build" : self.handle_build, + "info" : self.handle_info, "keepalive" : self.handle_keepalive, "repoupdate" : self.handle_repoupdate, "repo_create": self.handle_repo_create, @@ -655,6 +657,11 @@ class CliServer(Cli): sub_create.add_argument("inputs", nargs="+", help=_("Path to input packages.")) sub_create.add_argument("action", action="store_const", const="repo_create") + def parse_command_info(self): + sub_info = self.sub_commands.add_parser("info", + help=_("Dump some information about this machine.")) + sub_info.add_argument("action", action="store_const", const="info") + def handle_keepalive(self): self.server.update_info() @@ -669,6 +676,11 @@ class CliServer(Cli): pakfire.repo_create(path, self.args.inputs, **self.pakfire_args) + def handle_info(self): + info = self.server.info() + + print "\n".join(info) + class CliBuilderIntern(Cli): def __init__(self): diff --git a/python/pakfire/config.py b/python/pakfire/config.py index 6fb9b2980..38dd012fa 100644 --- a/python/pakfire/config.py +++ b/python/pakfire/config.py @@ -187,13 +187,17 @@ class Config(object): "i486" : [ "i486", "i586", "i686", "x86_64", ], # ARM - "armv5tel" : [ "armv5tel", "armv5tejl", ], + "armv5tel" : [ "armv5tel", "armv5tejl", "armv7l", ], "armv7hl " : [ "armv7l", ], } + ret = [] for host, can_be_built in host_arches.items(): if self.host_arch in can_be_built: - yield host + ret.append(host) + + ret.sort() + return reversed(ret) def host_supports_arch(self, arch): """ diff --git a/python/pakfire/server.py b/python/pakfire/server.py index 369b2348c..9799628ff 100644 --- a/python/pakfire/server.py +++ b/python/pakfire/server.py @@ -40,6 +40,7 @@ import pakfire.repository import pakfire.util from pakfire.constants import * +from pakfire.i18n import _ CHUNK_SIZE = 1024**2 # 1M @@ -230,14 +231,12 @@ class Server(object): """ return socket.gethostname() - def update_info(self): - # Get the current load average. - loadavg = ", ".join(["%.2f" % l for l in os.getloadavg()]) - - # Get all supported architectures. - arches = sorted([a for a in self.config.supported_arches]) - arches = " ".join(arches) + @property + def uname(self): + return os.uname()[4] + @property + def cpu_model(self): # Determine CPU model cpuinfo = {} with open("/proc/cpuinfo") as f: @@ -256,8 +255,19 @@ class Server(object): cpuinfo[key] = value - cpu_model = cpuinfo.get("model name", "Could not be determined") + ret = None + if self.uname.startswith("arm"): + try: + ret = "%(Hardware)s - %(Processor)s" % cpuinfo + except KeyError: + pass + else: + ret = cpuinfo.get("model name", None) + + return ret or _("Could not be determined") + @property + def memory(self): # Determine memory size memory = 0 with open("/proc/meminfo") as f: @@ -268,9 +278,42 @@ class Server(object): except: pass else: - memory = int(b) + memory = int(b) * 1024 + + return memory + + def info(self): + ret = [] + + ret.append("") + ret.append(" PAKFIRE %s" % PAKFIRE_VERSION) + ret.append("") + ret.append(" %-20s: %s" % (_("Hostname"), self.hostname)) + ret.append("") + + # Hardware information + ret.append(" %s:" % _("Hardware information")) + ret.append(" %-16s: %s" % (_("CPU model"), self.cpu_model)) + ret.append(" %-16s: %s" % (_("Memory"), pakfire.util.format_size(self.memory))) + ret.append("") + ret.append(" %-16s: %s" % (_("Native arch"), self.config.host_arch)) + + header = _("Supported arches") + for arch in self.config.supported_arches: + ret.append(" %-16s: %s" % (header, arch)) + header = "" + ret.append("") + + return ret + + def update_info(self): + # Get the current load average. + loadavg = ", ".join(["%.2f" % l for l in os.getloadavg()]) + + # Get all supported architectures. + arches = " ".join([a for a in self.config.supported_arches]) - self.conn.update_host_info(loadavg, cpu_model, memory, arches) + self.conn.update_host_info(loadavg, self.cpu_model, self.memory, arches) def upload_file(self, filename, build_id): # Get the hash of the file.