Example #1
0
def on_job(msg):
	'Main Worker, Process the job.'
	print "Received Job: %r" % msg.body
	strJob = json.loads(msg.body)
	if strJob[0]=="job":
		SMB.sendStatus(strJob[1])		
		handle_Worker(strJob[1])
	else:
		print "That's not My Job:"
		print "Head:",strJob[0]
		print "Body:",strJob[1]
	msg.ack()
Example #2
0
    def ConnectServer(self, host, port):
        if self.ep == 'ncan_ip_tcp':
            self.debug(0, 'Using ncan_ip_tcp endpoint')
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.sock.settimeout(self.timeout)
            try:
                self.debug(0, 'Connecting to ', host, ':', str(port))
                self.sock.connect((host, port))
                self.connected = 1
            except:
                self.debug(0, 'Failed to connect')
                return False
            return True
        elif self.ep == 'ncan_np':
            self.debug(0, 'Using ncan_np endpoint')
            self.debug(0, 'Doing SMB Negotiation')
            try:
                self.sock = SMB.SMB(self.smb_serv_name,
                                    host,
                                    my_name=self.smb_my_name,
                                    sess_port=port,
                                    timeout=self.timeout)
            except SMB.SessionError:
                self.debug(1, 'SMB Negotiation Failed')
                return False
            self.debug(0, 'Doing SMB SessionSetupAndX')
            try:
                self.sock.login(self.smb_user, self.smb_pass)
            except SMB.SessionError:
                self.debug(1, 'SMB SessionSetupAndX Failed')
                return False
            self.debug(0, 'Connecting to SMB Share ', self.smb_share)
            try:
                self.smb_tid = self.sock.connect_tree(self.smb_share,
                                                      '?????\x00',
                                                      self.smb_pass)
            except SMB.SessionError:
                self.debug(1, 'Failed to connected to share: ', self.smb_share)
                return False
            self.debug(0, 'Opening named pipe ', self.smb_pipe,
                       ' for reading/writing')
            try:
                self.smb_fid = self.sock.nt_create(self.smb_tid, self.smb_pipe)
            except SMB.SessionError:
                self.debug(1, 'Failed to open pipe: ', self.smb_pipe)
                return False

            self.connected = 1
            return True
        else:
            self.debug(1, 'Unknown DCERPC endpoint')
            return False
Example #3
0
def dispatch_jobs(ch):
	print "Dispatch Jobs: Job one. "
	job = build_Job(r'Job One')
	SMB.send_job(job)
Example #4
0
def on_connect():
	SMB.createStatusChannel()
	SMB.createJobsSender()	
	handle_Dispatcher()	#Call task dispatcher delegate.
Example #5
0
import logging
from tornado.ioloop import IOLoop
from stormed import Connection, Message
import simplejson as json
import SMB

#=================================================================
global handle_Dispatcher

def on_connect():
	SMB.createStatusChannel()
	SMB.createJobsSender()	
	handle_Dispatcher()	#Call task dispatcher delegate.

def build_Job(jobCMD):
	strJob = ["job","do job"]
	strJob[1] = jobCMD
	strJob = json.dumps(strJob)	
	msgJob = Message(strJob)
	return msgJob
	
#Just for test.	
def dispatch_jobs(ch):
	print "Dispatch Jobs: Job one. "
	job = build_Job(r'Job One')
	SMB.send_job(job)
	
if __name__ == '__main__':
	handle_Dispatcher = dispatch_jobs
	SMB.start(on_connect)
Example #6
0
def do_job(job):
	SMB.sendStatus("Job Begin: %r"%job)
	print "Doing Job:", job
	time.sleep(2)
	SMB.sendStatus("Job Finish: %r"%job)
Example #7
0
def on_connect():
	SMB.createStatusChannel()
	SMB.createJobsReceiver(on_job)
def dispatchJobs():
    for i in range(0, 10):
        job = build_Job(r'Job %2d' % i)
        print "Dispatch Job:", i
        SMB.send_job(job)
Desc:
	The dispatch jobs example, show the code logic.
Author: WangEQ, SuperMap GIS Institute.
All rights reserved.
"""

import math
import time
import sys

import logging
from tornado.ioloop import IOLoop
from stormed import Connection, Message
import simplejson as json

import SMB
import SMB_Dispatch


#=================================================================
def dispatchJobs():
    for i in range(0, 10):
        job = build_Job(r'Job %2d' % i)
        print "Dispatch Job:", i
        SMB.send_job(job)


if __name__ == '__main__':
    SMB_Dispatch.handle_Dispatcher = dispatchJobs
    SMB.start(SMB_Dispatch.on_connect)
Example #10
0
def dispatchJobs():
    for i in range(0, 10):
        job = build_Job(r"Job %2d" % i)
        print "Dispatch Job:", i
        SMB.send_job(job)
Example #11
0
SMPP,SuperMap Parallel Processor
Desc:
	The dispatch jobs example, show the code logic.
Author: WangEQ, SuperMap GIS Institute.
All rights reserved.
"""

import math
import time
import sys

import logging
from tornado.ioloop import IOLoop
from stormed import Connection, Message
import simplejson as json

import SMB
import SMB_Dispatch

# =================================================================
def dispatchJobs():
    for i in range(0, 10):
        job = build_Job(r"Job %2d" % i)
        print "Dispatch Job:", i
        SMB.send_job(job)


if __name__ == "__main__":
    SMB_Dispatch.handle_Dispatcher = dispatchJobs
    SMB.start(SMB_Dispatch.on_connect)
Example #12
0
def do_job(job):
	print "Job ToUDB:", job
	SMB.sendStatus("Job Begin: %r"%job)
	SMUP_Image.Tif2UDBOne(job,"H:\SRTM\UDB",False)
	SMB.sendStatus("Job Finish: %r"%job)
Example #13
0
def do_gms(job):
	print "Job ToUDB:", job
	SMB.sendStatus("Job Begin: %r"%job)
	runGMS(job)
	SMB.sendStatus("Job Finish: %r"%job)
Example #14
0
def do_empty(job):
	SMB.sendStatus("Job Empty: %r"%job)
Example #15
0
# coding: GB2312
#!/usr/bin/env python

"""
SMPP,SuperMap Parallel Processor
Desc:
	The Worker example to process jobs from SMB. 
Author: WangEQ, SuperMap GIS Institute.
All rights reserved.
"""

import math
import time
import sys

import SMB
import SMB_Worker

#=================================================================
def do_job(job):
	print "Do Job:", job
	SMB.sendStatus("Job Begin: %r"%job)
	print "Doing something:", job
	time.sleep(2)
	SMB.sendStatus("Job Finish: %r"%job)
	
if __name__ == '__main__':
	SMB_Worker.handle_Processor = do_job	
	SMB.start(SMB_Worker.on_connect)