Пример #1
0
    def closeConnection(self):
        if not self._mysql:
            return

        self._mysql.close()
        MLAB.removeSqlDatabase(self._mysql)
        self._mysql = None
Пример #2
0
 def closeConnection(self):
   if not self._mysql:
     return
     
   self._mysql.close()
   MLAB.removeSqlDatabase(self._mysql)
   self._mysql = None
Пример #3
0
def installOsiriXPlugin():
  # Make sure OsiriX is running beforehand. Due to the modified environment of
  # MeVisLab OsiriX may behave differently than usual when started from this
  # environment...
  if MLAB.macIsApplicationRunning('com.rossetantoine.osirix'):
    MLAB.macOpenFileInApplication(os.path.join(ctx.package().binPath(),'PlugIns','OsiriXMeVisLabBridge.osirixplugin'), 'com.rossetantoine.osirix')
  else:
    MLAB.showInformation('OsiriX must be running to install the plugin. Please start OsiriX.', 'The plugin will be handed to OsiriX for installation. Click on the Install button again after launching OsiriX.', 'OsiriXBridge', ctx.window())
Пример #4
0
def installPlugin():
  # Make sure OsiriX is running beforehand. Due to the modified environment of
  # MeVisLab OsiriX may behave differently than usual when started from this
  # environment...
  if MLAB.macIsApplicationRunning('com.rossetantoine.osirix'):
    MLAB.openFile(os.path.join(ctx.package().binPath(),'PlugIns','OsiriXMeVisLabBridge.osirixplugin'))
  else:
    MLAB.showInformation('OsiriX must be running to install the plugin. Please start OsiriX.', 'The plugin will be handed to OsiriX for installation. Click on the Install button again after launching OsiriX.', 'OsiriXBridge', ctx.window())
Пример #5
0
def filenameChanged(field=None):
  filename = ctx.expandFilename(ctx.field("filename").stringValue())
  if MLABFileManager.exists(filename):
    if MLABFileManager.isDir(filename):
      MLAB.logWarning("LocalAnalyzeLoad.filename - File is a directory (" + filename + ")")
    else:
      ctx.field("AnalyzeHeader.filename").setStringValue(filename)
  else:
    if not filename == "":
      MLAB.logWarning("LocalAnalyzeLoad.filename - File does not exist (" + filename + ")")
    ctx.field("AnalyzeHeader.filename").setStringValue("")
    
  parseFile(filename)
Пример #6
0
def filenameChanged(field=None):
    filename = ctx.expandFilename(ctx.field("filename").stringValue())
    if MLABFileManager.exists(filename):
        if MLABFileManager.isDir(filename):
            MLAB.logWarning(
                "LocalAnalyzeLoad.filename - File is a directory (" +
                filename + ")")
        else:
            ctx.field("AnalyzeHeader.filename").setStringValue(filename)
    else:
        if not filename == "":
            MLAB.logWarning(
                "LocalAnalyzeLoad.filename - File does not exist (" +
                filename + ")")
        ctx.field("AnalyzeHeader.filename").setStringValue("")

    parseFile(filename)
Пример #7
0
def tryUpdate():
    """Execute the CLI module, but don't warn about missing inputs (used
    for autoUpdate).  Returns error messages that can be displayed if
    explicitly run (cf. update())."""

    global execution
    execution = CLIExecution()

    execution.start()
    if ctx.field('runInBackground_WIP').value:
        _pollProcessStatus()
    else:
        while execution.isRunning():
            MLAB.processEvents()
            time.sleep(0.1)
        ec = execution.wait()
        if ec:
            return execution.errorDescription
Пример #8
0
 def openConnection(self,host,user,password,db):      
   if self._mysql and self._mysql.isOpen():
     self.closeConnection()
     
   self._mysql = MLAB.addSqlDatabase('Mysql')
   self._mysql.setHostName(host)
   self._mysql.setUserName(user)
   self._mysql.setPassword(password)
   self._mysql.setDatabaseName(db)
   self._mysql.setPort(3306)
   self._mysql.open()
   
   valid = self._mysql.isOpen()
   if not valid:
     self.closeConnection()
Пример #9
0
    def openConnection(self, host, user, password, db):
        if self._mysql and self._mysql.isOpen():
            self.closeConnection()

        self._mysql = MLAB.addSqlDatabase('Mysql')
        self._mysql.setHostName(host)
        self._mysql.setUserName(user)
        self._mysql.setPassword(password)
        self._mysql.setDatabaseName(db)
        self._mysql.setPort(3306)
        self._mysql.open()

        valid = self._mysql.isOpen()
        if not valid:
            self.closeConnection()
Пример #10
0
    def openConnection(self, host, user, password, db):
        if self._pgsql and self._pgsql.isOpen():
            self.closeConnection()

        self._pgsql = MLAB.addSqlDatabase('Postgres')
        self._pgsql.setHostName(host)
        self._pgsql.setUserName(user)
        self._pgsql.setPassword(password)
        self._pgsql.setDatabaseName(db)
        self._pgsql.setPort(5432)
        self._pgsql.open()

        valid = self._pgsql.isOpen()
        if not valid:
            print("could not open")
            self.closeConnection()
Пример #11
0
 def openConnection(self,host,user,password,db):      
   if self._pgsql and self._pgsql.isOpen():
     self.closeConnection()
     
   self._pgsql = MLAB.addSqlDatabase('Postgres')
   self._pgsql.setHostName(host)
   self._pgsql.setUserName(user)
   self._pgsql.setPassword(password)
   self._pgsql.setDatabaseName(db)
   self._pgsql.setPort(5432)
   self._pgsql.open()
   
   valid = self._pgsql.isOpen()
   if not valid:
     print("could not open")
     self.closeConnection()
Пример #12
0
def processOnce():
   commandList = ctx.field("commandList").value;
   isVerbose = ctx.field("isVerbose").value;
   isProcessEvents = ctx.field("isProcessEvents").value;
   isProcessInventorQueue = ctx.field("isProcessInventorQueue").value;
   sleep = ctx.field("sleep").value;
   commands = commandList.split('\n')
   for i in range(0, len(commands)):
     command = commands[i]
     if ( (command != '') and (command[0] != '#') ):
       if (isVerbose):
         MLAB.log("CommandBox ... " + command);
       ctx.parent().field(command).touch();
       if (isProcessEvents):
         MLAB.processEvents();
       if (isProcessInventorQueue):
         MLAB.processInventorQueue();
       MLAB.msleep(sleep);
Пример #13
0
def processOnce():
    commandList = ctx.field("commandList").value
    isVerbose = ctx.field("isVerbose").value
    isProcessEvents = ctx.field("isProcessEvents").value
    isProcessInventorQueue = ctx.field("isProcessInventorQueue").value
    sleep = ctx.field("sleep").value
    commands = commandList.split('\n')
    for i in range(0, len(commands)):
        command = commands[i]
        if ((command != '') and (command[0] != '#')):
            if (isVerbose):
                MLAB.log("CommandBox ... " + command)
            ctx.parent().field(command).touch()
            if (isProcessEvents):
                MLAB.processEvents()
            if (isProcessInventorQueue):
                MLAB.processInventorQueue()
            MLAB.msleep(sleep)
Пример #14
0
def _executeScript(script):
  tmp = MLABFileManager.getTmpDir()
  if not tmp[-1] == "/":
    tmp += "/"
  now = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
  
  file = MLABFileManager.getUniqueFilename(tmp,now,".scp")
  MLABFileManager.writeStringToFile(file,script)
  
  winscp = ctx.expandFilename("$(LOCAL)/winscp416.exe")
  
  cmd = "\"" + winscp + "\" /script=\"" + file + "\""
  
  proc = MLAB.newProcess()
  proc.addArgument(cmd)
  proc.setStdOutHandler(ctx,"_procStdOut")
  proc.setStdErrHandler(ctx,"_procStdErr")
  proc.setExitedHandler(ctx,"_procFinished")
  
  global _processes
  _processes[proc] = file
  
  proc.run()
Пример #15
0
def _executeScript(script):
  tmp = MLABFileManager.getTmpDir()
  if not tmp[-1] == "/":
    tmp += "/"
  now = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
  
  file = MLABFileManager.getUniqueFilename(tmp,now,".scp")
  MLABFileManager.writeStringToFile(file,script)
  
  winscp = ctx.expandFilename("$(LOCAL)/winscp416.exe")
  
  cmd = "\"" + winscp + "\" /script=\"" + file + "\""
  
  proc = MLAB.newProcess()
  proc.addArgument(cmd)
  proc.setStdOutHandler(ctx,"_procStdOut")
  proc.setStdErrHandler(ctx,"_procStdErr")
  proc.setExitedHandler(ctx,"_procFinished")
  
  global _processes
  _processes[proc] = file
  
  proc.run()
Пример #16
0
def _procStdErr(proc):
  MLAB.log(proc.readStdErr())
Пример #17
0
def ShowEatDicomOptions():
  MLAB.runCommandInConsole(MLABFileManager.getExecutable("eatDicom"), ["-help"], "", "", "Dicom Import Options Help", ctx.window());
def showGuide():
    MLAB.openFile(
        os.path.join(ctx.package().documentationPath(), 'Publish',
                     'OsiriXMeVisLabBridge.pdf'))
Пример #19
0
def SetDefaultEatDicomOptions():
  ctx.field("eatDicomOptions").setStringValue(MLAB.variable("EatDicomOptions"));
Пример #20
0
def _procStdOut(proc):
  MLAB.log(proc.readStdOut())
def call():
    success = False
    ctx.field("callSucceeded").value = success
    prog = ctx.field("executable").value
    args = str(ctx.field("arguments").value).split()
    workingdir = ctx.field("workingDirectory").value
    g_Process = MLAB.newProcess()
    #global g_Process
    MLAB.processEvents(False)
    MLAB.log(prog + " is started with the following options:")
    MLAB.log(args)
    if g_Process:
        g_Process.kill()
    if g_Process:
        MLAB.deleteProcess(g_Process)
    g_Process = MLAB.newProcess()
    g_Process.clearArguments()
    g_Process.addArgument(prog)
    g_Process.addArguments(args)
    g_Process.setWorkDir(workingdir)
    if ctx.field("outputToLogWindow").value:
        g_Process.setStdOutHandler(ctx, "processOut")
        g_Process.setStdErrHandler(ctx, "processOut")
        g_Process.setExitedHandler(ctx, "processExit")
    g_Process.setUserInfo(prog)
    g_Process.run()
    g_Process.waitForLaunch()
    if g_Process.isRunning():
        MLAB.log(prog + " is running")
        success = True
    else:
        MLAB.log(prog + " failed to start")
        success = False
    MLAB.processEvents(True)
    if g_Process:
        g_Process.waitForExit()
    if g_Process:
        MLAB.deleteProcess(g_Process)
    ctx.field("callSucceeded").value = success
Пример #22
0
def _procStdErr(proc):
  MLAB.log(proc.readStdErr())
Пример #23
0
def SetDefaultEatDicomOptions():
  ctx.field("eatDicomOptions").setStringValue(MLAB.variable("EatDicomOptions"))
Пример #24
0
def ShowEatDicomOptions():
  MLAB.runCommandInConsole(MLABFileManager.getExecutable("eatDicom"), ["-help"], "", "", "Dicom Import Options Help", ctx.window())
Пример #25
0
def showPlugin():
  MLAB.openFile(os.path.join(ctx.package().binPath(),'PlugIns'))
Пример #26
0
def showPlugin():
  MLAB.openFile(os.path.join(ctx.package().binPath(),'PlugIns'))
Пример #27
0
def _procStdOut(proc):
  MLAB.log(proc.readStdOut())
def processExit(p):
    MLAB.log("The following process has finished: " + p.userInfo())