diff options
| -rw-r--r-- | module/gui/MainWindow.py | 11 | ||||
| -rw-r--r-- | module/gui/connector.py | 13 | ||||
| -rwxr-xr-x | pyLoadCore.py | 15 | ||||
| -rwxr-xr-x | pyLoadGui.py | 15 | 
4 files changed, 52 insertions, 2 deletions
| diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py index 53de8cd54..744518adb 100644 --- a/module/gui/MainWindow.py +++ b/module/gui/MainWindow.py @@ -122,9 +122,11 @@ class MainWindow(QMainWindow):          self.addMenu = QMenu()          packageAction = self.addMenu.addAction("Package")          linkAction = self.addMenu.addAction("Links") +        containerAction = self.addMenu.addAction("Container")          self.connect(self.actions["add"], SIGNAL("triggered()"), self.slotAdd)          self.connect(packageAction, SIGNAL("triggered()"), self.slotShowAddPackage)          self.connect(linkAction, SIGNAL("triggered()"), self.slotShowAddLinks) +        self.connect(containerAction, SIGNAL("triggered()"), self.slotShowAddContainer)      def init_tabs(self):          """ @@ -230,6 +232,15 @@ class MainWindow(QMainWindow):          """          self.emit(SIGNAL("addPackage"), name, ids) +    def slotShowAddContainer(self): +        """ +            action from add-menu +            show file selector, emit upload +        """ +        fileNames = QFileDialog.getOpenFileNames(self, "Container Öffnen", "", "All Container Types (*.dlc *.ccf *.rsdf *.txt);;DLC (*.dlc);;CCF (*.ccf);;RSDF (*.rsdf);;Text Files (*.txt)") +        for name in fileNames: +            self.emit(SIGNAL("addContainer"), str(name)) +          def slotPushPackageToQueue(self):          """              push collector pack to queue diff --git a/module/gui/connector.py b/module/gui/connector.py index 4ac635200..e52cf42ff 100644 --- a/module/gui/connector.py +++ b/module/gui/connector.py @@ -304,3 +304,16 @@ class connector(QThread):              self.emit(SIGNAL("proxy_error"), "removeFile")          finally:              self.mutex.unlock() +     +    def uploadContainer(self, filename, type, content): +        """ +            upload a container +        """ +        self.mutex.lock() +        try: +            self.proxy.upload_container(filename, type, content) +        except: +            self.emit(SIGNAL("proxy_error"), "uploadContainer") +        finally: +            self.mutex.unlock() +         diff --git a/pyLoadCore.py b/pyLoadCore.py index 7cf83389e..9e9da2c4b 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -44,7 +44,8 @@ from sys import stdout  import thread
  import time
  from time import sleep -from shutil import copyfile
 +from shutil import copyfile +from tempfile import NamedTemporaryFile
  from module.file_list import File_List
  from module.network.Request import Request
 @@ -494,7 +495,17 @@ class ServerMethods():              self.core.file_list.packager.resetFileStatus(id)      def restart_file(self, fileid): -        self.core.file_list.packager.resetFileStatus(fileid)
 +        self.core.file_list.packager.resetFileStatus(fileid) +     +    def upload_container(self, filename, type, content): +        th = NamedTemporaryFile(mode="w", suffix="."+type, delete=False) +        th.write(content) +        path = th.name +        th.close() +        pid = self.core.file_list.packager.addNewPackage(filename) +        cid = self.core.file_list.collector.addLink(path) +        self.move_file_2_package(cid, pid)
 +        self.core.file_list.save()
      #def move_urls_up(self, ids):
      #    for id in ids:
 diff --git a/pyLoadGui.py b/pyLoadGui.py index 5e13dd080..f075db710 100755 --- a/pyLoadGui.py +++ b/pyLoadGui.py @@ -28,6 +28,8 @@ from PyQt4.QtGui import *  from uuid import uuid4 as uuid +from os.path import basename +  from module.gui.ConnectionManager import *  from module.gui.connector import *  from module.gui.MainWindow import * @@ -109,6 +111,7 @@ class main(QObject):          self.connect(self.mainWindow, SIGNAL("pushPackageToQueue"), self.slotPushPackageToQueue)          self.connect(self.mainWindow, SIGNAL("restartDownload"), self.slotRestartDownload)          self.connect(self.mainWindow, SIGNAL("removeDownload"), self.slotRemoveDownload) +        self.connect(self.mainWindow, SIGNAL("addContainer"), self.slotAddContainer)      def slotShowConnector(self):          """ @@ -377,6 +380,18 @@ class main(QObject):          for fileid in ids:              self.connector.addFileToPackage(fileid, packid) +    def slotAddContainer(self, path): +        """ +            emitted from main window +            add container +        """ +        filename = basename(path) +        type = "".join(filename.split(".")[-1]) +        fh = open(path, "r") +        content = fh.read() +        fh.close() +        self.connector.uploadContainer(filename, type, content) +          def slotSaveMainWindow(self, state, geo):          """              save the window geometry and toolbar/dock position to config file | 
