if app.execution.state == gc3libs.Run.State.NEW: print("Failed submitting application, check log for errors.") sys.exit(1) else: print("SquareApplication successfully submitted," " remote job ID is: %s" % app.execution.lrms_jobid) # Periodically check the status of your application. while app.execution.state in [ gc3libs.Run.State.SUBMITTED, gc3libs.Run.State.RUNNING, ]: time.sleep(5) # This call will contact the resource(s) and get the current # job state core.update_job_state(app) print("Job state is now %s " % app.execution.state) print("Fetching job output...") # You can specify a different `download_dir` option if you want to # override the value used in the GdemoSimpleApp initialization # (app.output_dir). # By default overwrite is False. If the output directory exists, it # will be renamed by appending a unique numerical suffix in the form # of output_dir.~N~ with N the first available number. core.fetch_output(app, overwrite=False) # after calling, `fetch_output` the job is in TERMINATED state and # GC3Pie won't act on it any more
# Submit your application. core.submit(app) # After submssion, you have to check the application for its state: print "Job id: %s" % app.execution.lrms_jobid # Periodically check the status of your application. while app.execution.state in [ gc3libs.Run.State.SUBMITTED, gc3libs.Run.State.RUNNING, ]: try: print "Job in status %s " % app.execution.state time.sleep(5) # This call will contact the resource(s) and get the current # job state core.update_job_state(app) sys.stdout.write("[ %s ]\r" % app.execution.state) sys.stdout.flush() except: raise print "Job is now in state %s. Fetching output." % app.execution.state # You can specify a different `download_dir` option if you want to # override the value used in the GdemoSimpleApp initialization # (app.output_dir). # By default overwrite is False. If the output directory exists, it # will be renamed by appending a unique numerical suffix in the form # of output_dir.~N~ with N the first available number. core.fetch_output(app, overwrite=False)