فهرست منبع

HUE-13. app_reg should show app's author

For backward compatibility, the author is "Unknown" for apps that are already
registered.
bc Wong 16 سال پیش
والد
کامیت
ed955094de
2فایلهای تغییر یافته به همراه15 افزوده شده و 10 حذف شده
  1. 9 7
      tools/app_reg/app_reg.py
  2. 6 3
      tools/app_reg/registry.py

+ 9 - 7
tools/app_reg/app_reg.py

@@ -84,7 +84,9 @@ def get_app_info(app_loc):
   save_cwd = os.getcwd()
   os.chdir(app_loc)
   try:
-    cmdv = [ common.ENV_PYTHON, 'setup.py', '--name', '--version', '--description' ]
+    cmdv = [ common.ENV_PYTHON, 'setup.py',
+             '--name', '--version', '--description',
+             '--author' ]
     LOG.debug("Running '%s'" % (' '.join(cmdv),))
     popen = subprocess.Popen(cmdv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     res = popen.wait()
@@ -94,7 +96,7 @@ def get_app_info(app_loc):
       LOG.error("Error getting application info from %s:\n%s" % (app_loc, stderr))
       raise OSError(stderr)
     LOG.debug("Command output:\n<<<\n%s\n>>>" % (stdout,))
-    return stdout.split('\n')[:3]
+    return stdout.split('\n')[:4]
   finally:
     os.chdir(save_cwd)
 
@@ -104,12 +106,12 @@ def _do_install_one(reg, app_loc):
   LOG.info("=== Installing app at %s" % (app_loc,))
   try:
     app_loc = os.path.realpath(app_loc)
-    app_name, version, desc = get_app_info(app_loc)
+    app_name, version, desc, author = get_app_info(app_loc)
   except (ValueError, OSError), ex:
     LOG.error(ex)
     return False
 
-  app = registry.DesktopApp(app_name, version, app_loc, desc)
+  app = registry.DesktopApp(app_name, version, app_loc, desc, author)
   if reg.contains(app):
     LOG.warn("=== %s is already installed" % (app,))
     return True
@@ -131,10 +133,10 @@ def do_list():
   """List all apps. Returns True/False."""
   reg = registry.AppRegistry()
   apps = reg.get_all_apps()
-  LOG.info("%-20s %-7s %s" % ('Name', 'Version', 'Path'))
-  LOG.info("%s %s %s" % ('-' * 20, '-' * 7, '-' * 50))
+  LOG.info("%-18s %-7s %-15s %s" % ('Name', 'Version', 'Author', 'Path'))
+  LOG.info("%s %s %s %s" % ('-' * 18, '-' * 7, '-' * 15, '-' * 35))
   for app in sorted(apps):
-    LOG.info("%-20s %-7s %s" % (app.name, app.version, app.path))
+    LOG.info("%-18s %-7s %-15s %s" % (app.name, app.version, app.author, app.path))
   return True
 
 

+ 6 - 3
tools/app_reg/registry.py

@@ -48,6 +48,7 @@ class AppRegistry(object):
       reg_file.close()
 
       for app_json in app_list:
+        app_json.setdefault('author', 'Unknown')        # Added after 0.9
         app = DesktopApp.create(app_json)
         self._apps[app.name] = app
 
@@ -122,13 +123,14 @@ class DesktopApp(object):
   """
   @staticmethod
   def create(json):
-    return DesktopApp(json['name'], json['version'], json['path'], json['desc'])
+    return DesktopApp(json['name'], json['version'], json['path'], json['desc'], json['author'])
 
-  def __init__(self, name, version, path, desc):
+  def __init__(self, name, version, path, desc, author):
     self.name = name
     self.version = version
     self.path = path
     self.desc = desc
+    self.author = author
 
   def __str__(self):
     return "%s (version %s)" % (self.name, self.version)
@@ -139,7 +141,8 @@ class DesktopApp(object):
     return cmp((self.name, self.version), (other.name, other.version))
 
   def jsonable(self):
-    return dict(name=self.name, version=self.version, path=self.path, desc=self.desc)
+    return dict(name=self.name, version=self.version, path=self.path,
+                desc=self.desc, author=self.author)
 
   def find_ext_pys(self):
     """find_ext_pys() -> A list of paths for all ext-py packages"""