コード例 #1
0
ファイル: htracker.py プロジェクト: CGRU/cgru
def sendJob( i_port):

    # Prepare action object.
    act = dict()
    act['user_name'] = cgruconfig.VARS['USERNAME']
    act['host_name'] = cgruconfig.VARS['HOSTNAME']
    act['type'] = 'jobs'
    act['ids'] = [Options.jobid]

    # Set environment for env-blocks.
    act['block_mask'] = Options.envblocks
    par = dict()
    par['environment'] = dict()
    par['environment']['TRACKER_ADDRESS'] = cgruconfig.VARS['HOSTNAME']
    par['environment']['TRACKER_PORT'] = str(i_port)
    act['params'] = par
    data = json.dumps({'action':act}, sort_keys=True, indent=4)
    print( data)
    res = afnetwork.sendServer( data)
    print( res)

    # Reset depend mask for dep-blocks.
    act['block_mask'] = Options.depblocks
    par = dict()
    par['depend_mask'] = ''
    act['params'] = par
    data = json.dumps({'action':act}, sort_keys=True, indent=4)
    print( data)
    res = afnetwork.sendServer( data)
    print( res)

    # Flush printed text to stdout out.
    sys.stdout.flush()
コード例 #2
0
def sendJob( i_port):

    # Prepare action object.
    act = dict()
    act['user_name'] = cgruconfig.VARS['USERNAME']
    act['host_name'] = cgruconfig.VARS['HOSTNAME']
    act['type'] = 'jobs'
    act['ids'] = [Options.jobid]

    # Set environment for env-blocks.
    act['block_mask'] = Options.envblocks
    par = dict()
    par['environment'] = dict()
    par['environment']['TRACKER_ADDRESS'] = cgruconfig.VARS['HOSTNAME']
    par['environment']['TRACKER_PORT'] = str(i_port)
    act['params'] = par
    data = json.dumps({'action':act}, sort_keys=True, indent=4)
    print( data)
    res = afnetwork.sendServer( data)
    print( res)

    # Reset depend mask for dep-blocks.
    act['block_mask'] = Options.depblocks
    par = dict()
    par['depend_mask'] = ''
    act['params'] = par
    data = json.dumps({'action':act}, sort_keys=True, indent=4)
    print( data)
    res = afnetwork.sendServer( data)
    print( res)

    # Flush printed text to stdout out.
    sys.stdout.flush()
コード例 #3
0
ファイル: af.py プロジェクト: eoyilmaz/cgru
    def send(self, verbose=False):
        """Missing DocString

        :param verbose:
        :return:
        """
        if len(self.blocks) == 0:
            print('Error: Job has no blocks')

        self.fillBlocks()

        # Set folder if empty:
        if "folders" not in self.data:
            self.data["folders"] = dict()
            # Try to set output folder from files:
            for block in self.blocks:
                if "files" in block.data and len(block.data["files"]):
                    self.data["folders"][block.data['name']] = os.path.dirname(block.data["files"][0])

        # Set branch if empty:
        if 'branch' not in self.data:
            if 'output' in self.data['folders']:
                self.data['branch'] = self.data['folders']['output']
            elif 'input' in self.data['folders']:
                self.data['branch'] = self.data['folders']['input']
            else:
                self.data['branch'] = self.blocks[0].data['working_directory']

        obj = {"job": self.data}
        # print(json.dumps( obj))

        return afnetwork.sendServer(json.dumps(obj), verbose)
コード例 #4
0
def sendAction(i_type, i_mask, i_operation, i_params=None):
    action = dict()
    action['type'] = i_type
    action['user_name'] = ActionUser
    action['host_name'] = ActionHost
    action['mask'] = i_mask

    if i_operation is not None:
        operation = dict()
        operation['type'] = i_operation
        action['operation'] = operation

    if i_params is not None:
        action['params'] = i_params

    afnetwork.sendServer(json.dumps({'action': action}))
コード例 #5
0
    def send(self, verbose=False):
        """Missing DocString

        :param verbose:
        :return:
        """
        if len(self.blocks) == 0:
            print('Error: Job has no blocks')

        self.fillBlocks()

        # Set folder if empty:
        if "folders" not in self.data:
            self.data["folders"] = dict()
            # Try to set output folder from files:
            for block in self.blocks:
                if "files" in block.data and len(block.data["files"]):
                    self.data["folders"][block.data['name']] = os.path.dirname(block.data["files"][0])

        # Set branch if empty:
        if 'branch' not in self.data:
            if 'output' in self.data['folders']:
                self.data['branch'] = self.data['folders']['output']
            elif 'input' in self.data['folders']:
                self.data['branch'] = self.data['folders']['input']
            else:
                self.data['branch'] = self.blocks[0].data['working_directory']

        obj = {"job": self.data}
        # print(json.dumps( obj))

        return afnetwork.sendServer(json.dumps(obj), verbose)
コード例 #6
0
ファイル: emulate.py プロジェクト: AlbertR/cgru
def sendAction(i_type, i_mask, i_operation, i_params=None):
	action = dict()
	action['type'] = i_type
	action['user_name'] = ActionUser
	action['host_name'] = ActionHost
	action['mask'] = i_mask

	if i_operation is not None:
		operation = dict()
		operation['type'] = i_operation
		action['operation'] = operation

	if i_params is not None:
		action['params'] = i_params

	afnetwork.sendServer(json.dumps({'action': action}), False, False)
コード例 #7
0
    def send(self, verbose=False):
        if len(self.blocks) == 0:
            print('Error: Job has no blocks')
            return False
        self.fillBlocks()

        obj = {"job": self.data}
        #print(json.dumps( obj))

        return afnetwork.sendServer(json.dumps(obj), False, verbose)[0]
コード例 #8
0
ファイル: af.py プロジェクト: AlbertR/cgru170
	def send( self, verbose = False):
		if len( self.blocks) == 0:
			print('Error: Job has no blocks')
			return False
		self.fillBlocks()

		obj = {"job": self.data }
		#print(json.dumps( obj))

		return afnetwork.sendServer( json.dumps( obj), False, verbose)[0]
コード例 #9
0
    def _sendRequest(self, verbose=False):
        if self.action is None:
            print('ERROR: Action is not set.')
            return None

        receive = (self.action == 'get')
        obj = {self.action: self.data}
        #print(json.dumps( obj))
        output = afnetwork.sendServer(json.dumps(obj), receive, verbose)

        if output[0] == True:
            return output[1]
        else:
            return None
コード例 #10
0
ファイル: af.py プロジェクト: AlbertR/cgru170
	def _sendRequest(self, verbose = False):
		if self.action is None:
			print('ERROR: Action is not set.')
			return None

		receive = ( self.action == 'get')
		obj = { self.action: self.data }
		#print(json.dumps( obj))
		output = afnetwork.sendServer( json.dumps( obj), receive, verbose)

		if output[0] == True:
			return output[1]
		else:
			return None
コード例 #11
0
ファイル: af.py プロジェクト: cg-cnu/cgru
	def send(self, verbose=False):
		"""Missing DocString

		:param verbose:
		:return:
		"""
		if len(self.blocks) == 0:
			print('Error: Job has no blocks')
		# return False
		self.fillBlocks()

		obj = {"job": self.data}
		# print(json.dumps( obj))

		return afnetwork.sendServer(json.dumps(obj), True, verbose)
コード例 #12
0
    def send(self, verbose=False):
        """Missing DocString

		:param verbose:
		:return:
		"""
        if len(self.blocks) == 0:
            print('Error: Job has no blocks')
        # return False
        self.fillBlocks()

        obj = {"job": self.data}
        # print(json.dumps( obj))

        return afnetwork.sendServer(json.dumps(obj), True, verbose)
コード例 #13
0
def _sendRequest(action, requestData, verbose=False, without_answer=False):
    """Missing DocString

    :param bool verbose:
    :return:
    """
    data = {'user_name': cgruconfig.VARS['USERNAME'],
            "host_name": cgruconfig.VARS['HOSTNAME']}
    data.update(requestData)
    obj = {action: data}
    # print(json.dumps(obj))
    output = afnetwork.sendServer(json.dumps(obj), verbose, i_without_answer=without_answer)
    if output[0] is True:
        return output[1]
    else:
        return None
コード例 #14
0
ファイル: afcmd.py プロジェクト: CGRU/cgru
def _sendRequest(action, requestData, verbose=False, without_answer=False):
    """Missing DocString

    :param bool verbose:
    :return:
    """
    data = {'user_name': cgruconfig.VARS['USERNAME'],
            "host_name": cgruconfig.VARS['HOSTNAME']}
    data.update(requestData)
    obj = {action: data}
    # print(json.dumps(obj))
    output = afnetwork.sendServer(json.dumps(obj), verbose, i_without_answer=without_answer)
    if output[0] is True:
        return output[1]
    else:
        return None
コード例 #15
0
def sendAction(i_type, i_mask, i_operation, i_params=None):
	action = dict()
	action['type'] = i_type
	action['user_name'] = Options.user
	action['host_name'] = Options.name
	action['mask'] = i_mask

	if i_operation is not None:
		operation = dict()
		operation['type'] = i_operation
		action['operation'] = operation

	if i_params is not None:
		action['params'] = i_params

	# print( json.dumps( {'action': action}))
	status, answer = afnetwork.sendServer(json.dumps({'action': action}), False)
	return status
コード例 #16
0
    def _sendRequest(self, verbose=False, without_answer=False):
        """Missing DocString

        :param bool verbose:
        :return:
        """
        if self.action is None:
            print('ERROR: Action is not set.')
            return None

        obj = {self.action: self.data}
        # print(json.dumps( obj))
        output = afnetwork.sendServer(json.dumps(obj), verbose, without_answer)
        self.__init__()
        if output[0] is True:
            return output[1]
        else:
            return None
コード例 #17
0
ファイル: emulate_renders.py プロジェクト: AlbertR/cgru
def sendAction(i_type, i_mask, i_operation, i_params=None):
	action = dict()
	action['type'] = i_type
	action['user_name'] = Options.user
	action['host_name'] = Options.name
	action['mask'] = i_mask

	if i_operation is not None:
		operation = dict()
		operation['type'] = i_operation
		action['operation'] = operation

	if i_params is not None:
		action['params'] = i_params

	# print( json.dumps( {'action': action}))
	status, answer = afnetwork.sendServer(json.dumps({'action': action}), False, False)
	return status
コード例 #18
0
ファイル: af.py プロジェクト: RISEFX/cgru
    def _sendRequest(self, verbose=False):
        """Missing DocString

        :param bool verbose:
        :return:
        """
        if self.action is None:
            print('ERROR: Action is not set.')
            return None

        obj = {self.action: self.data}
        #print(json.dumps( obj))
        output = afnetwork.sendServer(json.dumps(obj), verbose)
        self.__init__()
        if output[0] is True:
            return output[1]
        else:
            return None
コード例 #19
0
ファイル: af.py プロジェクト: paulwinex/cgru
	def send(self, verbose=False):
		"""Missing DocString

		:param verbose:
		:return:
		"""
		if len(self.blocks) == 0:
			print('Error: Job has no blocks')

		self.fillBlocks()

		# Set folder if empty:
		if not "folders" in self.data:
			self.data["folders"] = dict()
			# Try to set output folder from files:
			for block in self.blocks:
				if "files" in block.data and len(block.data["files"]):
					self.data["folders"]["output"] = os.path.dirname( block.data["files"][0])

		obj = {"job": self.data}
		# print(json.dumps( obj))

		return afnetwork.sendServer(json.dumps(obj), True, verbose)
コード例 #20
0
    def send(self, verbose=False):
        """Missing DocString

		:param verbose:
		:return:
		"""
        if len(self.blocks) == 0:
            print('Error: Job has no blocks')

        self.fillBlocks()

        # Set folder if empty:
        if not "folders" in self.data:
            self.data["folders"] = dict()
            # Try to set output folder from files:
            for block in self.blocks:
                if "files" in block.data and len(block.data["files"]):
                    self.data["folders"]["output"] = os.path.dirname(
                        block.data["files"][0])

        obj = {"job": self.data}
        # print(json.dumps( obj))

        return afnetwork.sendServer(json.dumps(obj), verbose)
コード例 #21
0
ファイル: afsend.py プロジェクト: sugf/cgru
Parser.add_option('-c', '--cycles',  dest='cycles',  type  ='int',        default=1,     help='Cycles for operation repeat')
Parser.add_option('-t', '--time',    dest='time',    type  ='float',      default=-1,    help='Sleep time between cycles')
Parser.add_option('-V', '--verbose', dest='verbose', action='store_true', default=False, help='Verbose mode')
(Options, Args) = Parser.parse_args()

if len( Args ) < 1:
	print('Send file to Afanasy server.')
	print('Usage: %s file' % sys.argv[0])
	sys.exit(1)

File = Args[0]

if not os.path.isfile( File):
	print('File not founded:')
	print( File)
	sys.exit(1)

file = open( File, 'rb')
data = file.read( os.path.getsize( File))
file.close

for i in range( 0, Options.cycles):
	status, answer = afnetwork.sendServer( data, Options.recv, Options.verbose)
	if not status:
		sys.exit(1)
	if Options.recv and answer:
		print( answer)
	if Options.time > 0:
		time.sleep( Options.time)

コード例 #22
0
Options, Args = Parser.parse_args()

if len(Args) < 1:
    print('Send file to Afanasy server.')
    print('Usage: %s file' % sys.argv[0])
    sys.exit(1)

File = Args[0]

if not os.path.isfile(File):
    print('File not found:')
    print(File)
    sys.exit(1)

with open(File, 'rb') as f:
    data = f.read(os.path.getsize(File))

for i in range(0, Options.cycles):

    status, answer = afnetwork.sendServer(data, Options.verbose)

    if not status:
        sys.exit(1)

    if answer:
        print(answer)

    if Options.time > 0:
        time.sleep(Options.time)