Пример #1
0
    def finishInit(self):
        global decodeFile
        global Document
        global DocumentController
        from cadnano.document import Document
        from cadnano.fileio.decode import decodeFile
        from cadnano.controllers.documentcontroller import DocumentController
        from cadnano.views.pathview import pathstyles as styles

        styles.setFontMetrics()

        doc = Document()
        self._document = self.createDocument(base_doc=doc)

        if os.environ.get('CADNANO_DISCARD_UNSAVED', False) and not self.ignoreEnv():
            self.dontAskAndJustDiscardUnsavedChanges = True
        self.dontAskAndJustDiscardUnsavedChanges = True
        util.loadAllPlugins()

        if self.argns.interactive:
            print("Welcome to cadnano's debug mode!")
            print("Some handy locals:")
            print("\ta\tcadnano.app() (the shared cadnano application object)")
            print("\td()\tthe last created Document")

            def d():
                return self._document

            print("\tw()\tshortcut for d().controller().window()")

            def w():
                return self._document.controller().window()

            print("\tp()\tshortcut for d().selectedInstance().reference()")

            def p():
                return self._document.selectedInstance().reference()

            print("\tpi()\tthe PartItem displaying p()")

            def pi():
                part_instance = self._document.selectedInstance()
                return w().pathroot.partItemForPart(part_instance)

            print("\tvh(i)\tshortcut for p().reference().getStrandSets(i)")

            def strandsets(id_num):
                return p().reference().getStrandSets(id_num)

            print("\tvhi(i)\tvirtualHelixItem displaying vh(i)")

            def vhi(id_num):
                partitem = pi()
                return partitem.vhItemForIdNum(id_num)

            print("\tquit()\tquit (for when the menu fails)")
            print("\tgraphicsItm.findChild()  see help(pi().findChild)")
            interact('', local={'a': self, 'd': d, 'w': w,
                                'p': p, 'pi': pi, 'vhi': vhi,
                                })
Пример #2
0
    def finishInit(self):
        global decodeFile
        global Document
        global DocumentController
        from cadnano.document import Document
        from cadnano.fileio.nnodecode import decodeFile
        from cadnano.gui.controllers.documentcontroller import DocumentController
        from cadnano.gui.views.pathview import pathstyles as styles

        doc = Document()
        self._document = self.createDocument(base_doc=doc)

        styles.setFontMetrics()

        os.environ['CADNANO_DISCARD_UNSAVED'] = 'True'  # added by Nick
        if os.environ.get('CADNANO_DISCARD_UNSAVED', False) and not self.ignoreEnv():
            self.dontAskAndJustDiscardUnsavedChanges = True
        util.loadAllPlugins()

        if self.argns.interactive:
            print("Welcome to cadnano's debug mode!")
            print("Some handy locals:")
            print("\ta\tcadnano.app() (the shared cadnano application object)")
            print("\td()\tthe last created Document")

            def d():
                return self._document

            print("\tw()\tshortcut for d().controller().window()")

            def w():
                return self._document.controller().window()

            print("\tp()\tshortcut for d().selectedInstance().reference()")

            def p():
                return self._document.selectedInstance().reference()

            print("\tpi()\tthe PartItem displaying p()")

            def pi():
                part_instance = self._document.selectedInstance()
                return w().pathroot.partItemForPart(part_instance)

            print("\tvh(i)\tshortcut for p().reference().getStrandSets(i)")

            def strandsets(id_num):
                return p().reference().getStrandSets(id_num)

            print("\tvhi(i)\tvirtualHelixItem displaying vh(i)")

            def vhi(id_num):
                partitem = pi()
                return partitem.vhItemForIdNum(id_num)

            print("\tquit()\tquit (for when the menu fails)")
            print("\tgraphicsItm.findChild()  see help(pi().findChild)")
            interact('', local={'a': self, 'd': d, 'w': w,
                                'p': p, 'pi': pi, 'vhi': vhi,
                                })
Пример #3
0
    def finishInit(self):
        global decode
        global Document
        global DocumentController
        from cadnano.document import Document
        from cadnano.fileio.nnodecode import decode
        from cadnano.gui.controllers.documentcontroller import DocumentController
        from cadnano.gui.views.pathview import pathstyles as styles
        doc = Document()
        self.d = self.newDocument(base_doc=doc)
        styles.setFontMetrics()
        
        os.environ['CADNANO_DISCARD_UNSAVED'] = 'True' ## added by Nick 
        if os.environ.get('CADNANO_DISCARD_UNSAVED', False) and not self.ignoreEnv():
            self.dontAskAndJustDiscardUnsavedChanges = True
        if os.environ.get('CADNANO_DEFAULT_DOCUMENT', False) and not self.ignoreEnv():
            self.shouldPerformBoilerplateStartupScript = True
        util.loadAllPlugins()
        if "-i" in self.argv:
            print("Welcome to cadnano's debug mode!")
            print("Some handy locals:")
            print("\ta\tcadnano.app() (the shared cadnano application object)")
            print("\td()\tthe last created Document")
            def d():
                return self.d

            print("\tw()\tshortcut for d().controller().window()")
            def w():
                return self.d.controller().window()

            print("\tp()\tshortcut for d().selectedPart()")
            def p():
                return self.d.selectedPart()

            print("\tpi()\tthe PartItem displaying p()")
            def pi():
                return w().pathroot.partItemForPart(p())

            print( "\tvh(i)\tshortcut for p().virtualHelix(i)")
            def vh(vhref):
                return p().virtualHelix(vhref)

            print( "\tvhi(i)\tvirtualHelixItem displaying vh(i)")
            def vhi(vhref):
                partitem = pi()
                vHelix = vh(vhref)
                return partitem.vhItemForVH(vHelix)
                
            print("\tquit()\tquit (for when the menu fails)")
            print("\tgraphicsItm.findChild()  see help(pi().findChild)")
            interact('', local={'a':self, 'd':d, 'w':w,\
                                'p':p, 'pi':pi, 'vh':vh, 'vhi':vhi,\
                                })
Пример #4
0
    def finishInit(self):
        global decode
        global Document
        global DocumentController
        from cadnano.document import Document
        from cadnano.fileio.nnodecode import decode
        from cadnano.gui.controllers.documentcontroller import DocumentController
        from cadnano.gui.views import styles
        doc = Document()
        self.d = self.newDocument(base_doc=doc)
        styles.setFontMetrics()
        
        os.environ['CADNANO_DISCARD_UNSAVED'] = 'True' ## added by Nick 
        if os.environ.get('CADNANO_DISCARD_UNSAVED', False) and not self.ignoreEnv():
            self.dontAskAndJustDiscardUnsavedChanges = True
        if os.environ.get('CADNANO_DEFAULT_DOCUMENT', False) and not self.ignoreEnv():
            self.shouldPerformBoilerplateStartupScript = True
        util.loadAllPlugins()
        if "-i" in self.argv:
            print("Welcome to cadnano's debug mode!")
            print("Some handy locals:")
            print("\ta\tcadnano.app() (the shared cadnano application object)")
            print("\td()\tthe last created Document")
            def d():
                return self.d

            print("\tw()\tshortcut for d().controller().window()")
            def w():
                return self.d.controller().window()

            print("\tp()\tshortcut for d().selectedPart()")
            def p():
                return self.d.selectedPart()

            print("\tpi()\tthe PartItem displaying p()")
            def pi():
                return w().pathroot.partItemForPart(p())

            print( "\tvh(i)\tshortcut for p().virtualHelix(i)")
            def vh(vhref):
                return p().virtualHelix(vhref)

            print( "\tvhi(i)\tvirtualHelixItem displaying vh(i)")
            def vhi(vhref):
                partitem = pi()
                vHelix = vh(vhref)
                return partitem.vhItemForVH(vHelix)
                
            print("\tquit()\tquit (for when the menu fails)")
            print("\tgraphicsItm.findChild()  see help(pi().findChild)")
            interact('', local={'a':self, 'd':d, 'w':w,\
                                'p':p, 'pi':pi, 'vh':vh, 'vhi':vhi,\
                                })
Пример #5
0
 def addPluginAtPath(self, fname):
     self.fileopendialog.close()
     fname = str(fname[0])
     print("Attempting to open plugin %s" % fname)
     try:
         zf = zipfile.ZipFile(fname, "r")
     except Exception as e:
         self.failWithMsg("Plugin file seems corrupt: %s." % e)
         return
     tdir = tempfile.mkdtemp()
     try:
         for f in zf.namelist():
             if f.endswith("/"):
                 os.makedirs(os.path.join(tdir, f))
         for f in zf.namelist():
             if not f.endswith("/"):
                 zf.extract(f, tdir)
     except Exception as e:
         self.failWithMsg("Extraction of plugin archive failed: %s." % e)
         return
     files_in_zip = [(f, os.path.join(tdir, f)) for f in os.listdir(tdir)]
     try:
         self.confirmDestructiveIfNecessary(files_in_zip)
         self.removePluginsToBeOverwritten(files_in_zip)
         self.movePluginsIntoPluginsFolder(files_in_zip)
     except OSError:
         print(
             "Couldn't copy files into plugin directory, attempting\
                again after boosting privileges."
         )
         if platform.system() == "Darwin":
             self.darwinAuthedMvPluginsIntoPluginsFolder(files_in_zip)
         elif platform.system() == "Linux":
             self.linuxAuthedMvPluginsIntoPluginsFolder(files_in_zip)
         else:
             print("Can't boost privelages on platform %s" % platform.system())
     loadedAPlugin = util.loadAllPlugins()
     if not loadedAPlugin:
         print("Unable to load anythng from plugin %s" % fname)
     self.readPreferences()
     shutil.rmtree(tdir)
Пример #6
0
 def addPluginAtPath(self, fname):
     self.fileopendialog.close()
     fname = str(fname[0])
     print("Attempting to open plugin %s" % fname)
     try:
         zf = zipfile.ZipFile(fname, 'r')
     except Exception as e:
         self.failWithMsg("Plugin file seems corrupt: %s." % e)
         return
     tdir = tempfile.mkdtemp()
     try:
         for f in zf.namelist():
             if f.endswith('/'):
                 os.makedirs(os.path.join(tdir, f))
         for f in zf.namelist():
             if not f.endswith('/'):
                 zf.extract(f, tdir)
     except Exception as e:
         self.failWithMsg("Extraction of plugin archive failed: %s." % e)
         return
     files_in_zip = [(f, os.path.join(tdir, f)) for f in os.listdir(tdir)]
     try:
         self.confirmDestructiveIfNecessary(files_in_zip)
         self.removePluginsToBeOverwritten(files_in_zip)
         self.movePluginsIntoPluginsFolder(files_in_zip)
     except OSError:
         print("Couldn't copy files into plugin directory, attempting\
                again after boosting privileges.")
         if platform.system() == 'Darwin':
             self.darwinAuthedMvPluginsIntoPluginsFolder(files_in_zip)
         elif platform.system() == 'Linux':
             self.linuxAuthedMvPluginsIntoPluginsFolder(files_in_zip)
         else:
             print("Can't boost privelages on platform %s" %
                   platform.system())
     loadedAPlugin = util.loadAllPlugins()
     if not loadedAPlugin:
         print("Unable to load anythng from plugin %s" % fname)
     self.readPreferences()
     shutil.rmtree(tdir)