def runJavaIJapp(memory, appName, args, env=None): env = env or {} getEnviron = Config.getDomain().importFromPlugin('xmipp3', 'Plugin').getEnviron env.update(getEnviron(xmippFirst=False)) # Add scipion variables env[SCIPION_DOMAIN] = Config.SCIPION_DOMAIN env[SCIPION_HOME_VAR]= Config.SCIPION_HOME if Config.debugOn(): env[SCIPION_DEBUG] = "1" # Add out python path to the PATH env["PATH"] = ":".join([sys.executable, env.get("PATH", "")]) # Try chimera try: chimeraPlugin = Config.getDomain().importFromPlugin('chimera', 'Plugin', doRaise=True) env["CHIMERA_LAUNCHER"] = chimeraPlugin.getProgram() + " %s" except Exception as e: pass args = getJavaIJappArguments(memory, appName, args) print('java %s' % args) # return subprocess.Popen('java ' + args, shell=True, env=env) cmd = ['java'] + shlex.split(args) return subprocess.Popen(cmd, env=env)
def _drawNode(self, node): """ Allocate node with x=0 and y=0. """ try: parents = node.getParents() if not parents: print("EMPTY NODE ask JM") return maxParent = parents[0] for p in parents[1:]: if p.y > maxParent.y: maxParent = p siblings = maxParent.getChilds() if len(siblings) == 1: node.x = maxParent.x node.y = maxParent.y + self.DY else: rightSibling = siblings[0] for s in siblings: if s.x > rightSibling.x: rightSibling = s node.x = rightSibling.x + rightSibling.width / 2 + self.DX + node.width / 2 node.y = rightSibling.y except Exception as e: from pyworkflow.utils import envVarOn if Config.debugOn(): print("Can't draw node: %s" % node, e) import traceback traceback.print_stack() else: # Do nothing return
def startDebugger(password='******'): if Config.debugOn(): try: # FIXME: rpdb2 does not support python 3 from rpdb2 import start_embedded_debugger print("Starting debugger...") start_embedded_debugger(password) except Exception: print( "Error importing rpdb2 debugging module, consider installing winpdb." )
def runCommand(command, env=None, cwd=None): """ Execute command with given environment env and directory cwd """ # First let us create core dumps if in debug mode if Config.debugOn(env): import resource resource.setrlimit(resource.RLIMIT_CORE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY)) # This is like "ulimit -u 99999999", so we can create core dumps # TODO: maybe have to set PBS_NODEFILE in case it is used by "command" # (useful for example with gnu parallel) check_call(command, shell=True, stdout=sys.stdout, stderr=sys.stderr, env=env, cwd=cwd)
def runJobMPISlave(mpiComm): """ This slave will be receiving commands to execute until 'None' is received. """ rank = mpiComm.Get_rank() hostname = getLocalHostName() print(" Running MPIWorker: ", rank) exitResult = 0 # Listen for commands until we get 'None' cwd = None # We run without changing directory by default env = None # And we don't change the environment either! while True: # Receive command in a non-blocking way req_recv = mpiComm.irecv(source=0, tag=TAG_RUN_JOB + rank) while True: done, command = req_recv.test() if done: break sleep(1) print(" Worker %s(rank %d) received command." % (hostname, rank)) # We need to convert to string because req_recv.test() returns bytes or None if command == 'None': print(" Stopping...") return else: command = loads(command) # Run the command and get the result (exit code or exception) try: if command.startswith("cwd="): cwd = command.split("=", 1)[-1] print(" Changing to dir %s ..." % cwd) elif command.startswith("env="): env = command.split("=", 1)[-1] env = eval(env) print(" Setting the environment...") if Config.debugOn(): print(env) else: runCommand(command, cwd=cwd, env=env) cwd = None # unset directory env = None # unset environment except Exception as e: print(" Error in process %d (rank %d)" % (os.getpid(), rank)) import traceback traceback.print_exc() exitResult = str(e) # Communicate to master, either error os success req_send = mpiComm.isend(exitResult, dest=0, tag=TAG_RUN_JOB + rank) t0 = time() while not req_send.test()[0]: sleep(1) if time() - t0 > TIMEOUT: msg = " Error in process %d, cannot send error message to master." print(msg % os.getpid()) break