Beispiel #1
0
 def SendSms2Server(self,message,phoneNumber):      
     sendMessage=message.decode('GBK').encode('UTF-8')
     fp=open(r'D:\Projects\boc\logs\sms.log','a+')
     b=NPBinding(url='http://xxx:xxx:xxx:xxx:8080/axis/services/SendSms?wsdl',tracefile=fp)
     b.SetAuth(AUTH.httpbasic,'sendsms','')
     b.sendSms(phoneNumber=phoneNumber,message=sendMessage)
     fp.close()
Beispiel #2
0
def insertJobOut(username, wkey, jobnum, outdir, edir):
   file=str(outdir)+"/tmp/sge/"+str(jobnum)
   command="python " + edir  + "/readout.py -f "+file
   child = os.popen(command)
   jobout = child.read().rstrip()
   err = child.close()

   if err:
	raise RuntimeError, 'ERROR: %s failed w/ exit code %d' % (command, err) 
   jobout=plaintext2html(re.sub('\'', "\"", jobout))
   kw = {'url':url}
   b = NPBinding(**kw)
   mesg=b.insertJobOut(a=username , c=wkey , b=jobnum, f=jobout)
Beispiel #3
0
def checkAllJobsFinished(username, wkey, service_name):
    kw = {'url':url}
    b = NPBinding(**kw)
    mesg=b.checkAllJobsFinished(a=username , c=wkey , b=service_name)
    
    data=json.dumps(mesg)
    wkey=json.loads(data)

    ret=str(wkey['return'])
    #print "JOBs checked:"+ret+"\n"
    if (ret.startswith("ERROR")):
                print service_name + ":" + ret + "\n"
                print "Check the service:"+service_name+"\n"
                sys.exit(2);
Beispiel #4
0
def updateJob( username, wkey, jobname, service_name, field, jobnum, result):
    #print "username="******", wkey="+str(wkey)+", jobname="+str(jobname)+", ser="+str(service_name)+", field="+str(field)+", jobnum="+str(jobnum)+", res="+str(result) 
    kw = {'url':url}
    b = NPBinding(**kw)
    mesg=b.updateJob(a=username , c=wkey , b=jobname, e=service_name , d=field, g=jobnum, f=result)
    
    data=json.dumps(mesg)
    wkey=json.loads(data)

    ret=str(wkey['return'])
    #print "JOB updated:"+ret+"\n"
    if (ret.startswith("ERROR")):
                print jobname + ":" + ret + "\n"
                print "Check the job#:"+jobnum+"\n"
                sys.exit(2);
def run():
	from ZSI.client import Binding, NamedParamBinding
	from stopeight.server.zsiTools import ABCPoint,ABCLine,ABCSymbol
	from stopeight.server import zsiTools
	from numpy import ndarray
	import sys
	import traceback
	from ZSI import TC

	from stopeight.server import server_include
	url=server_include.server_url+str(server_include.server_port)

	fp = open(__file__+'.log', 'a')
	b = NamedParamBinding(typesmodule=zsiTools,url=url, tracefile=fp)

	try:
	    input = ABCSymbol()
	    #line = ABCLine.from_numpy_array([[0,50],[25,25],[50,0],[70,70]])
	    line = ABCLine.from_numpy_array([[0,55],[25,25],[55,0]])
	    # for identifying echo in result
	    line.id=0
	    input.add_line(line)

	    # for identifying echo in result
	    input.id=0
	    for i in input.lines:
		print 'Input line: '
		for p in i:
		    print p.x,p.y
		    pass
	    print 'sending SOAP method: saveLine...'
	    # parameter name doesn't seem to matter
	    result = b.saveLine(sdklffjkdsla=input)
	    for i in result['ABCSymbol']:
		print 'Saved line id: %d'%(i.id)
		for p in i:
		    print p.x,p.y
		    pass

	except:
	    exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
	    print "*** print_tb:"
	    traceback.print_tb(exceptionTraceback, limit=1, file=sys.stdout)
	    print "*** print_exception:"
	    traceback.print_exception(exceptionType, exceptionValue, exceptionTraceback,
		                      limit=10, file=sys.stdout)
	fp.close()
Beispiel #6
0
def insertJob( username, wkey, com, jobname, service_name, jobnum, result):
    
    #print "username="******", wkey="+wkey+", com="+com+", jobname="+jobname+", ser="+service_name+", jobnum="+jobnum+", res="+result 
    #kw = {'url':url, 'tracefile':sys.stdout}
    kw = {'url':url}
    b = NPBinding(**kw)
    mesg=b.insertJob(a=username , c=wkey , b=com , e=jobname, d=service_name , f=jobnum, h=result)
    
    data=json.dumps(mesg)
    wkey=json.loads(data)

    ret=str(wkey['return'])
    #print "JOB inserted:"+ret+"\n"
    if (ret.startswith("ERROR")):
                print jobname + ":" + ret + "\n"
                print "Check the job#:"+jobnum+"\n"
                sys.exit(2);
def run():
    from ZSI.client import Binding, NamedParamBinding
    from stopeight.server.zsiTools import ABCPoint, ABCLine, ABCSymbol
    from stopeight.server import zsiTools

    # from numpy import *
    import sys
    import traceback
    from ZSI import TC

    from stopeight.server import server_include

    url = server_include.server_url + str(server_include.server_port)

    fp = open(__file__ + ".log", "a")
    b = NamedParamBinding(typesmodule=zsiTools, url=url, tracefile=fp)

    try:
        input = ABCSymbol()
        line = ABCLine()
        # This line id is going to be deleted
        line.id = 1
        input.add_line(line)

        # for identifying echo in result
        input.id = 0
        for i in input.lines:
            print "Input line id: %d" % (i.id)
        print "sending SOAP method: deleteLine..."
        # parameter name doesn't seem to matter
        result = b.deleteLine(sdklffjkdsla=input)
        for i in result["ABCSymbol"]:
            print "Deleted line id: %d" % (i.id)
            for p in i:
                print p.x, p.y
                pass

    except:
        exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
        print "*** print_tb:"
        traceback.print_tb(exceptionTraceback, limit=1, file=sys.stdout)
        print "*** print_exception:"
        traceback.print_exception(exceptionType, exceptionValue, exceptionTraceback, limit=10, file=sys.stdout)
    fp.close()
def run():
	from ZSI.client import Binding, NamedParamBinding
	from stopeight.server.zsiTools import ABCPoint,ABCLine,ABCSymbol
	from stopeight.server import zsiTools
	#from numpy import *
	import sys
	import traceback
	from ZSI import TC

	from stopeight.server import server_include
	url=server_include.server_url+str(server_include.server_port)

	fp = open(__file__+'.log', 'a')
	b = NamedParamBinding(typesmodule=zsiTools,url=url, tracefile=fp)

	try:
	    input = ABCSymbol()
	    line = ABCLine()

	    # the id of the line has to be known in advance
	    line.id=1
	    input.add_line(line)

	    # for identifying echo in result
	    input.id=0
	    for i in input.lines:
		print 'Input line id: %d'%(i.id)
	    print 'sending SOAP method: getLine...'
	    # parameter name doesn't seem to matter
	    result = b.getLine(sdklffjkdsla=input)
	    for i in result['ABCSymbol']:
		print 'Received line id: %d'%(i.id)
		for p in i:
		    print p.x,p.y
		    pass

	except:
	    exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
	    print "*** print_tb:"
	    traceback.print_tb(exceptionTraceback, limit=1, file=sys.stdout)
	    print "*** print_exception:"
	    traceback.print_exception(exceptionType, exceptionValue, exceptionTraceback,
		                      limit=10, file=sys.stdout)
	fp.close()
Beispiel #9
0
def main():

    try:
        parser = OptionParser()
        parser.add_option('-i',
                          '--inputparam',
                          help='input parameters for the workflow',
                          dest='inputparam')
        parser.add_option(
            '-p',
            '--defaultparam',
            help='defined parameter file that will be run on cluster',
            dest='defaultparam')
        parser.add_option('-u',
                          '--username',
                          help='defined user in the cluster',
                          dest='username')
        parser.add_option('-k',
                          '--wkey',
                          help='defined key for the workflow',
                          dest='wkey')
        parser.add_option('-w',
                          '--workflowfile',
                          help='workflow filename',
                          dest='workflowfile')
        parser.add_option('-d', '--dbhost', help='dbhost name', dest='dbhost')
        parser.add_option('-o',
                          '--outdir',
                          help='output directory in the cluster',
                          dest='outdir')
        (options, args) = parser.parse_args()
    except:
        print "OptionParser Error:for help use --help"
        sys.exit(2)

    INPUTPARAM = options.inputparam
    DEFAULTPARAM = options.defaultparam
    USERNAME = options.username
    WKEY = options.wkey
    WORKFLOWFILE = options.workflowfile
    DBHOST = options.dbhost
    OUTDIR = options.outdir

    if (DBHOST == None):
        DBHOST = "galaxyweb"
    if (USERNAME == None):
        USERNAME = getpass.getuser()
    if (WKEY == None):
        WKEY = "start"
    if (OUTDIR == None):
        OUTDIR = "~/out"
    if (INPUTPARAM != None):
        if path.isfile(INPUTPARAM) and access(INPUTPARAM, R_OK):
            INPUTPARAM = import_param(INPUTPARAM)
        else:
            INPUTPARAM = re.sub(" ", "", INPUTPARAM)
    #print INPUTPARAM
    #sys.exit()
    services = import_workflow(WORKFLOWFILE)

    url = "http://" + str(DBHOST) + ".umassmed.edu/pipeline/service.php"

    #kw = {'url':url, 'tracefile':sys.stdout}
    kw = {'url': url}
    b = NPBinding(**kw)
    wfname = os.path.splitext(basename(WORKFLOWFILE))[0]
    mesg = b.startWorkflow(a=INPUTPARAM,
                           c=DEFAULTPARAM,
                           b=USERNAME,
                           e=wfname,
                           d=WKEY,
                           f=OUTDIR)

    data = json.dumps(mesg)
    wkey = json.loads(data)

    ret = str(wkey['return'])
    print "WORKFLOW STARTED:" + ret + "\n"
    if (ret.startswith("ERROR")):
        print wfname + ":" + ret + "\n"
        print "Check the parameter files:\n"
        sys.exit(2)

    for service in services:
        br = 1
        while (br == 1):
            print service.servicename + ":" + wkey[
                'return'] + ":" + service.command
            res = json.loads(
                json.dumps(
                    b.startService(a=service.servicename,
                                   c=wkey['return'],
                                   b=service.command)))
            ret = str(res['return'])
            print ret + "\n"
            if (ret.startswith("RUNNING") and float(service.waittime) > 0):
                print service.waittime + "\n"
                time.sleep(float(service.waittime))
            elif (ret.startswith("ERROR")):
                print service.servicename + ":" + ret + "\n"
                print "Check the command:\n"
                print service.command + "\n"
                sys.exit(2)
            else:
                br = 0
    br = 1

    while (br == 1):
        res = json.loads(json.dumps(b.endWorkflow(a=wkey['return'])))
        ret = str(res['return'])
        print ret + "\n"
        if (ret.startswith("WRUNNING")):
            time.sleep(5)
        else:
            br = 0
Beispiel #10
0
from ZSI.client import NamedParamBinding as NPBinding
import sys
from ZSI.client import AUTH

b = NPBinding(url='http://:8080/axis/services/SendSms?wsdl',
              tracefile=sys.stdout)
b.SetAuth(AUTH.httpbasic, 'sendsms', '')
message = 'kkkkkkkkk'
a = message.decode('GBK').encode('UTF-8')
b.sendSms(phoneNumber='1111111111', message=a)
Beispiel #11
0
def main():

    try:
        parser = OptionParser()
        parser.add_option('-i', '--inputparam', help='input parameters for the workflow', dest='inputparam')
        parser.add_option('-p', '--defaultparam', help='defined parameter file that will be run on cluster', dest='defaultparam')
        parser.add_option('-u', '--username', help='defined user in the cluster', dest='username')
        parser.add_option('-k', '--wkey', help='defined key for the workflow', dest='wkey')
        parser.add_option('-w', '--workflowfile', help='workflow filename', dest='workflowfile')
        parser.add_option('-d', '--dbhost', help='dbhost name', dest='dbhost')
        parser.add_option('-o', '--outdir', help='output directory in the cluster', dest='outdir')
        (options, args) = parser.parse_args()
    except:
        print "OptionParser Error:for help use --help"
        sys.exit(2)

    INPUTPARAM      = options.inputparam
    DEFAULTPARAM    = options.defaultparam
    USERNAME        = options.username
    WKEY            = options.wkey 
    WORKFLOWFILE    = options.workflowfile
    DBHOST          = options.dbhost
    OUTDIR          = options.outdir

    if (DBHOST==None):
      DBHOST="galaxyweb"
    if (USERNAME==None):
      USERNAME=getpass.getuser()
    if (WKEY==None):
      WKEY="start"
    if (OUTDIR==None):
      OUTDIR="~/out"
    if (INPUTPARAM!=None):
        if path.isfile(INPUTPARAM) and access(INPUTPARAM, R_OK):
            INPUTPARAM = import_param(INPUTPARAM)
        else:
            INPUTPARAM = re.sub(" ", "", INPUTPARAM)
    #print INPUTPARAM
    #sys.exit()
    services=import_workflow(WORKFLOWFILE)
    
    url="http://"+str(DBHOST)+".umassmed.edu/pipeline/service.php"
   
    #kw = {'url':url, 'tracefile':sys.stdout}
    kw = {'url':url}
    b = NPBinding(**kw)
    wfname = os.path.splitext(basename(WORKFLOWFILE))[0]
    mesg=b.startWorkflow(a=INPUTPARAM , c=DEFAULTPARAM , b=USERNAME , e=wfname, d=WKEY , f=OUTDIR)
    
    data=json.dumps(mesg)
    wkey=json.loads(data)

    ret=str(wkey['return'])
    print "WORKFLOW STARTED:"+ret+"\n"
    if (ret.startswith("ERROR")):
                print wfname + ":" + ret + "\n"
                print "Check the parameter files:\n"
                sys.exit(2);

    for service in services:
        br=1
        while ( br==1):
            print service.servicename + ":" + wkey['return'] + ":" + service.command
            res=json.loads(json.dumps(b.startService(a=service.servicename, c=wkey['return'], b=service.command)))
            ret=str(res['return'])
            print ret + "\n"
            if (ret.startswith("RUNNING") and float(service.waittime)>0):
                print service.waittime+"\n"
                time.sleep(float(service.waittime))
            elif (ret.startswith("ERROR")):
                print service.servicename + ":" + ret + "\n"
                print "Check the command:\n"
                print service.command + "\n"
                sys.exit(2);
            else:
                br=0
    br=1
        
    while ( br==1):
        res=json.loads(json.dumps(b.endWorkflow(a=wkey['return'])))
        ret=str(res['return'])
        print ret + "\n"
        if (ret.startswith("WRUNNING")):
            time.sleep(5)
        else:
            br=0
def main():
    try:
        parser = OptionParser()
        parser.add_option('-i', '--inputparam', help='input parameters for the workflow', dest='inputparam')
        parser.add_option('-p', '--defaultparam', help='defined parameter file that will be run on cluster', dest='defaultparam')
        parser.add_option('-u', '--username', help='defined user in the cluster', dest='username')
        parser.add_option('-k', '--wkey', help='defined key for the workflow', dest='wkey')
        parser.add_option('-w', '--workflowfile', help='workflow filename', dest='workflowfile')
        parser.add_option('-d', '--dbhost', help='dbhost name', dest='dbhost')
        parser.add_option('-o', '--outdir', help='output directory in the cluster', dest='outdir')
        (options, args) = parser.parse_args()
    except:
        print "OptionParser Error:for help use --help"
        sys.exit(2)

    INPUTPARAM      = options.inputparam
    DEFAULTPARAM    = options.defaultparam
    USERNAME        = options.username
    WKEY            = options.wkey 
    WORKFLOWFILE    = options.workflowfile
    DBHOST          = options.dbhost
    OUTDIR          = options.outdir

    if (USERNAME==None):
      USERNAME=getpass.getuser()
    if (len(USERNAME)<3): 
        print "Error:Username doesn't exist"
        sys.exit(2)

    url="http://galaxyweb.umassmed.edu/dolphin_amazon/service.php"
    com="wget -qO- http://instance-data/latest/meta-data/public-ipv4"
    amazon_instance=str(os.popen(com).readline().rstrip())
    
    if (WKEY==None):
      WKEY="start"
    if (OUTDIR==None):
      OUTDIR="~/out"
    if (OUTDIR.find("/")==-1):
      OUTDIR="~/"+OUTDIR
    if (INPUTPARAM!=None):
        if path.isfile(INPUTPARAM) and access(INPUTPARAM, R_OK):
            INPUTPARAM = import_param(INPUTPARAM)
        else:
            INPUTPARAM = re.sub(" ", "", INPUTPARAM)

    services=import_workflow(WORKFLOWFILE)
    slen=str(len(services))    
     
    #kw = {'url':url, 'tracefile':sys.stdout}
    kw = {'url':url}
    b = NPBinding(**kw)
    wfname = os.path.splitext(basename(WORKFLOWFILE))[0]
    mesg=b.startWorkflow(a=INPUTPARAM , c=DEFAULTPARAM , b=USERNAME , e=wfname, d=WKEY , f=OUTDIR, i=slen, h=amazon_instance)
    
    data=json.dumps(mesg)
    wkey=json.loads(data)

    ret=str(wkey['return'])
    print "WORKFLOW STARTED:"+ret+"\n"
    if (ret.startswith("ERROR")):
                print wfname + ":" + ret + "\n"
                print "Check the parameter files:\n"
                sys.exit(2);

    for service in services:
        br=1
        while ( br==1):
            print service.servicename #+ ":" + wkey['return'] + ":" + service.command
            res=json.loads(json.dumps(b.startService(a=service.servicename, c=wkey['return'], b=service.command)))
            ret=str(res['return'])
            print ret + "\n"
            if (ret.startswith("RUNNING") and float(service.waittime)>0):
                #print service.waittime+"\n"
                time.sleep(float(service.waittime))
            elif (ret.startswith("ERROR")):
                #print service.servicename + ":" + ret + "\n"
                print "Check the command:\n"
                print service.command + "\n"
                sys.exit(2);
            else:
                br=0
    br=1
    print "All the services Ended"    
    while ( br==1):
        res=json.loads(json.dumps(b.endWorkflow(a=wkey['return'])))
        ret=str(res['return'])
        #print ret + "\n"
        if (ret.startswith("WRUNNING")):
            time.sleep(5)
        else:
            br=0