OSDN Git Service

Updates of installer
authorShyouzou Sugitani <shy@users.sourceforge.jp>
Sun, 28 Oct 2012 12:27:17 +0000 (21:27 +0900)
committerShyouzou Sugitani <shy@users.sourceforge.jp>
Sun, 28 Oct 2012 12:27:17 +0000 (21:27 +0900)
ChangeLog
lib/ninix/install.py
lib/ninix_main.py

index 29ed2b4..5f0a935 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun October 28 2012   Shyouzou Sugitani <shy@users.sourceforge.jp>
+       * コンソールへhttp, ftpのURIをDnDすることでもゴーストなどを
+         インストール出来るようにした.
+
 Wed October 10 2012   Shyouzou Sugitani <shy@users.sourceforge.jp>
        * バージョン4.99.3リリース.
        * dll/gomi.py:
index 4635edd..2968b26 100644 (file)
@@ -83,7 +83,7 @@ class Installer:
         # check archive format
         basename, ext = os.path.splitext(filename)
         ext = ext.lower()
-        if ext in ['.nar', '.zip']:
+        if ext in [b'.nar', b'.zip']:
             pass
         else:
             fatal('unknown archive format')
@@ -103,8 +103,11 @@ class Installer:
             if filename is None:
                 shutil.rmtree(tmpdir)
                 fatal('cannot download the archive file')
+        else:
+            filename = os.fsencode(filename)
+            self.check_archive(filename)
         try:
-            with zipfile.ZipFile(filename) as zf:
+            with zipfile.ZipFile(os.fsdecode(filename)) as zf: # XXX
                 for name in zf.namelist():
                     path = os.path.join(os.fsencode(tmpdir), os.fsencode(name))
                     dname, fname = os.path.split(path)
@@ -169,7 +172,6 @@ class Installer:
         return filetype
 
     def install(self, filename, homedir):
-        self.check_archive(filename)
         homedir = os.fsencode(homedir) # XXX
         tmpdir = self.extract_files(filename)
         filetype = self.get_file_type(tmpdir)
@@ -195,7 +197,7 @@ class Installer:
         if not os.path.exists(arcdir):
             os.makedirs(arcdir)
         basedir = arcdir
-        filename = os.path.join(basedir, os.path.basename(url))
+        filename = os.path.join(basedir, os.fsencode(os.path.basename(url)))
         try:
             with open(filename, 'wb') as ofile:
                 while 1:
@@ -209,7 +211,7 @@ class Installer:
         # check the format of the downloaded file
         self.check_archive(filename) ## FIXME
         try:
-            zf = zipfile.ZipFile(filename)
+            zf = zipfile.ZipFile(os.fsdecode(filename)) # XXX
         except:
             return None
         test_zip = zf.testzip()
index 0c4a78a..982d642 100644 (file)
@@ -1267,7 +1267,7 @@ class Console:
     def open_file_chooser(self):
         response = self.file_chooser.run()
         if response == Gtk.ResponseType.OK:
-            filename = self.file_chooser.get_filename()
+            filename = self.file_chooser.get_filename() # XXX: don't use os.fsencode() here
             self.app.do_install(filename)
             self.update()
         elif response == Gtk.ResponseType.CANCEL:
@@ -1315,13 +1315,13 @@ class Console:
                 urllib.parse.urlparse(uri)
             pathname = urllib.request.url2pathname(path)
             if scheme == 'file' and os.path.exists(pathname):
-                filelist.append(pathname)
+                filelist.append(pathname) # XXX: don't use os.fsencode() here
+            elif scheme == 'http' or scheme == 'ftp':
+                filelist.append(uri)
         if filelist:
-            filelist = [os.fsencode(filename) for filename in filelist]
             for filename in filelist:
                 self.app.do_install(filename)
             self.update()
-        return True
 
 
 class UsageDialog: