Selaa lähdekoodia

HUE-1509 [core] Truncate hue.pth instead of overwrite

Abraham Elmahrek 12 vuotta sitten
vanhempi
commit
5750f1b7b1
2 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 2 1
      tools/app_reg/app_reg.py
  2. 2 3
      tools/app_reg/pth.py

+ 2 - 1
tools/app_reg/app_reg.py

@@ -20,8 +20,9 @@ A tool to manage Hue applications. This does not stop/restart a
 running Hue instance.
 
 Usage:
-    %(PROG_NAME)s [flags] --install <path_to_app> [<path_to_app> ...]
+    %(PROG_NAME)s [flags] --install <path_to_app> [<path_to_app> ...] [--relative-paths]
         To register and install new application(s).
+        Add '--relative-paths' to the end of the args list to force the app manager to register the new application using its path relative to the hue root.
 
     %(PROG_NAME)s [flags] --remove <application_name>
         To unregister and remove an installed application.

+ 2 - 3
tools/app_reg/pth.py

@@ -115,9 +115,8 @@ class PthFile(object):
     Save the pth file
     Create a symlink to the path if it does not already exist.
     """
-    tmp_path = self._path + '.new'
-    file(tmp_path, 'w').write('\n'.join(sorted(self._entries)))
-    os.rename(tmp_path, self._path)
+    with open(self._path, 'w') as _file:
+      _file.write('\n'.join(sorted(self._entries)))
     LOG.info('=== Saved %s' % self._path)
 
   def sync(self, apps):