当前位置: 首页>>代码示例>>Python>>正文


Python GearmanClient.submit_job方法代码示例

本文整理汇总了Python中gearman.GearmanClient.submit_job方法的典型用法代码示例。如果您正苦于以下问题:Python GearmanClient.submit_job方法的具体用法?Python GearmanClient.submit_job怎么用?Python GearmanClient.submit_job使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gearman.GearmanClient的用法示例。


在下文中一共展示了GearmanClient.submit_job方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: videoCreationBatch

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
def videoCreationBatch():
    from auth import get_user, is_superuser
    if not is_superuser():
        return action_401()
    if request.method=="GET":
        chdir(config.INGEST_DIRECTORY)
        files=[f for f in listdir(getcwd()) if f[0] != '.']
        return json.dumps(files)
    else:
        from PIL import Image
        from shutil import move
        from helpers import getVideoInfo
        packet=request.json
        for up in packet:
            filepath=unicode(config.INGEST_DIRECTORY + up['filepath'])
	    new_file=unicode(config.MEDIA_DIRECTORY + up['id'] + ".mp4")
	    if path.isfile(new_file):
		return bundle_400("That file already exists; try another unique ID.")
            if path.isfile(filepath.encode('utf-8')):
                md=getVideoInfo(filepath.encode('utf-8'))
                poster = config.POSTERS_DIRECTORY + "%s.jpg" % (up["id"])
                thumb = config.POSTERS_DIRECTORY + "%s_thumb.jpg" % (up["id"])
                move(filepath.encode('utf-8'), new_file.encode('utf-8'))
                assets.update({"_id":up["pid"]},{"$set":{
                    "@graph.ma:frameRate":float(md["framerate"]),
                    "@graph.ma:averageBitRate":int(float(md["bitrate"])),
                    "@graph.ma:frameWidth":int(md["width"]),
                    "@graph.ma:frameHeight":int(md["height"]),
                    "@graph.ma:duration":int( round(float(md["duration"])) )/60,
                    "@graph.ma:locator": [
                        {
                            "@id": up["id"],
                            "ma:hasFormat": "video/mp4",
                            "ma:hasCompression": {"@id":"http://www.freebase.com/view/en/h_264_mpeg_4_avc","name": "avc.42E01E"}
                        },
                        {
                            "@id": up["id"],
                            "ma:hasFormat": "video/webm",
                            "ma:hasCompression": {"@id":"http://www.freebase.com/m/0c02yk5","name":"vp8.0"}
                        }
                    ]
                }})
                imgcmd = "avconv -i '%s' -q:v 1 -r 1 -t 00:00:01 -ss 00:00:30 -f image2 '%s'" % (new_file,poster)
                system(imgcmd.encode('utf-8'))
                chmod(poster,0775)
                im=Image.open(poster)
                im.thumbnail((160,90))
                im.save(thumb)
                chmod(thumb,0775)
                
                if not app.config.get('TESTING'):
                    from gearman import GearmanClient
                    client = GearmanClient(config.GEARMAN_SERVERS)
                    client.submit_job("generate_webm", str(up["id"]))
                else:
                    from ingest import generate_webm
                    result = generate_webm(file_id=up['id'])
                    if result == "ERROR":
                      raise Exception("Could not convert media file.")
	return "Success"
开发者ID:mindis,项目名称:byu-hummedia-api,代码行数:62,代码来源:resources.py

示例2: obj_create

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
    def obj_create(self, bundle, **kwargs):
        bundle.obj = Task(procedure_url=bundle.data["ordered_tasks"][0], 
                        input_dataset=bundle.data["input_dataset"], output_dataset=bundle.data["output_dataset"])
        
        bundle.obj.save()
        
        parent_task = bundle.obj
        for t_url in bundle.data["ordered_tasks"][1:]:
            if "aggregator" in t_url:
                continue
            temp_task = Task(procedure_url=t_url, parent=parent_task,
                                input_dataset=bundle.data["output_dataset"], output_dataset=bundle.data["output_dataset"])
            temp_task.save()
            parent_task = temp_task
            #statsd.gauge('outstanding_tasks', 1, delta=True)

        #statsd.gauge('outstanding_tasks', 1, delta=True)

        #now that we've created the dependency chain, we will schedule the first task
        dat = {}
        dat["task"] = bundle.data["ordered_tasks"][0]
        dat["task_id"] = bundle.obj.id
        dat["output_dataset"] = bundle.data["output_dataset"]
        dat["input_dataset"] = bundle.data["input_dataset"]
        dat["cassandra_nodes"] = CassandraNode.get_nodeip_list()
        client = GearmanClient(GearmanNode.get_nodeip_list())
        client.submit_job("pre_schedule", pickle.dumps(dat),background=True)
        
        return bundle.obj
开发者ID:ccarvalheira,项目名称:wsep,代码行数:31,代码来源:api.py

示例3: run

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
def run(simulation, run):
	rivers = simulation.rivers.all()
	start_point = simulation.start_point
	end_point = simulation.end_point
	start_elevation = usgs_elevation(start_point.x, start_point.y)
	end_elevation = usgs_elevation(end_point.x, end_point.y)
	river_length = 0 
	for river in rivers:
		river_length += river.geom.length

	# This is dumb, we need to do a proper calculation but for now this is good enough
	river_length_ft = river_length * 69.1 * 5280
	number_of_cross_sections = 1
	upstream_width = 30
	downstream_width = 30

	distance_ft = start_point.distance(end_point) * 69.1 * 5280

	channels = [
		{
			'length' : distance_ft, 
			'cross_sections' : number_of_cross_sections,
			'start_elevation' : start_elevation, 
			'end_elevation' : end_elevation,
			'upstream_width' : upstream_width, 
			'downstream_width': downstream_width
		},
	]

	model_parameters = {
		'maxtimesteps' : 80, 
		'time_step': 300, 
		'time_weight': 0.6, 
		'amplitude': 1999.5, 
		'period': 3.33, 
		'phase_angle': 1.67, 
		'start_time': 0.0, 
		'end_time': 1.667
	}

	run_parameters = {
		'channels': channels, 
		'model_parameters': model_parameters,
		'simulation_id': simulation.id, 
		'run_id': run.id
	}
	
	client = GearmanClient(settings.GEARMAN_SERVERS)
	jobdata = json.dumps(run_parameters)
	client.submit_job('fourpt', jobdata, background=True)

	return True
开发者ID:johnewart,项目名称:riversim,代码行数:54,代码来源:fourpt.py

示例4: deal

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
 def deal(self):
     self.write('work received<br>')
     new_client = GearmanClient(['192.168.5.41:4730'])
     current_request = new_client.submit_job('task_kanjia','heal the world')
     new_result = current_request.result
     print new_result
     self.write('work finished')
开发者ID:liruikaiyao,项目名称:workshop,代码行数:9,代码来源:gender_client.py

示例5: pushSocket

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
def pushSocket(queue):
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    serverAddr = ('0.0.0.0', 28282);
    sock.bind(serverAddr)

    send_thread = SendThread(sock, queue)
    send_thread.start()

    gm_client = GearmanClient(['localhost:4730'])

    while True:
        msg, addr = sock.recvfrom(2048)
        if not msg:
            continue
        #print "recevied:", msg, "from", addr

        try:
            data = json.loads(msg)
            topic = str(data['topic'])
            data['address'] = addr[0] + ':' + str(addr[1])
        except:
            continue

        gm_request = gm_client.submit_job(topic, json.dumps(data), background=False, wait_until_complete=False)

    sock.close()
开发者ID:ImDaneel,项目名称:robot,代码行数:28,代码来源:pushSocket.py

示例6: send_request

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
def send_request(req):
    new_client = GearmanClient([req.IP])

    s = time.time()
    request_dict={}
    request_dict["header"] = req.header
    request_dict["request"]= req.request
    if "pack_in" in req.params and req.params["pack_in"] == "0":
        current_request = new_client.submit_job(req.worker,request_dict)
    else:
        current_request = new_client.submit_job(req.worker,msgpack.packb(request_dict))

    if "pack_out" in req.params and req.params["pack_out"] == "0":
        current_result = current_request.result
    else:
        current_result = msgpack.unpackb(current_request.result)
    e = time.time()
    print "using time:%f" % (e-s)

    return current_result
开发者ID:doudou0o,项目名称:curlgm,代码行数:22,代码来源:curlgearmanclient.py

示例7: doWork_fetchDependencyInfo

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
def doWork_fetchDependencyInfo(params):
    """
        params = {
            'projectId':projectId,
            'projectPath':projectInfo['projectPath'],
            'appName':data['appName'],
            'dependencyType':1,
        }
    """
    client = GearmanClient([GearmanConfig.gearmanConnection])
    data = json.dumps(params)
    request = client.submit_job(JobList.Job_fetchDependencyInfo, data, wait_until_complete=True)
    return request.result
开发者ID:JasonZengJ,项目名称:puzzle,代码行数:15,代码来源:PuzzleBackGroundCommands.py

示例8: generate

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
def generate(image, options, force_creation = False):
  simulation = image.simulation

  points = options['points']
  for point in points:
    logging.debug("Point: %d,%d" % (point['x'], point['y']))
  natural_width = int(options['naturalWidth'])
  natural_height = int(options['naturalHeight'])
  image.channel_width_points = json.dumps(points)
  image.image_natural_width = natural_width
  image.image_natural_height = natural_height
  image.save()

  geotiff_image = simulation.aerialmap.filname
  channel_image = simulation.channelmap.filename
  width_image = simulation.channelwidthmap.filename

  if (not os.path.isfile(width_image)) or force_creation == True :
    logging.debug("Channel width map image %s doesn't exist, generating..." % (width_image))

    if image.job_handle and force_creation == False:
      logging.debug("Job handle: %s already exists, not re-queueing" % (image.job_handle))
      return None
    else:
        run_parameters = {
           'channel_image' : simulation.channel_image,
           'channel_width_image' : simulation.channel_width_image,
           'elevation_map_image' : elevation_image
        }

        client = GearmanClient(settings.GEARMAN_SERVERS)
        jobdata = json.dumps(run_parameters)
        jobrequest = client.submit_job('elevation_map', jobdata, background=True)
            
        simulation.elevation_map_job_handle = jobrequest.gearman_job.handle
        simulation.elevation_map_job_complete = False
        simulation.save()

        return None
  else:
    img = Image.open(width_image)
    return img
开发者ID:johnewart,项目名称:riversim,代码行数:44,代码来源:channel_width.py

示例9: generate

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
def generate(simulation_id, force_creation = False):
  simulation = Simulation.objects.get(pk = simulation_id)

  geotiff_image = simulation.aerial_geotiff
  channel_image = simulation.channel_image

      
  if (not os.path.isfile(channel_image)) or force_creation == True:

    if simulation.channel_tile_job_handle and force_creation == False:
        logging.debug("Job handle: %s already exists, not re-queueing" % (simulation.channel_tile_job_handle)) 
        return None
    else:
        logging.debug("Channel image %s doesn't exist, generating..." % (channel_image))

        run_parameters = {
          'tile_path': settings.RIVER_TILES_PATH,
          'geotiff_image': geotiff_image, 
          'channel_image': channel_image,
          'ortho_tiles': [tile.tile for tile in simulation.get_ortho_tiles()],
          'tile_width': 5000, 
          'tile_height': 5000 
        }

        client = GearmanClient(settings.GEARMAN_SERVERS)
        jobdata = json.dumps(run_parameters)
        jobrequest = client.submit_job('channel_image', jobdata, background=True)

        simulation.channel_tile_job_handle = jobrequest.gearman_job.handle
        simulation.channel_tile_job_complete = False
        simulation.save()

        return None

  else:  
    img = Image.open(channel_image)
    return img
开发者ID:johnewart,项目名称:riversim,代码行数:39,代码来源:channel_tiles.py

示例10: dir

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
#!/usr/bin/env python
#coding:utf8
# Author          : tuxpy
# Email           : [email protected]
# Last modified   : 2014-08-29 11:52:16
# Filename        : gearman_client.py
# Description     : 
from gearman import GearmanClient

new_client=GearmanClient(["192.168.8.116:1234"])
fd=open("亮剑.txt",'r')
line=fd.readline()
request=new_client.submit_job('pinyin',line)
print dir(request)

开发者ID:lujinda,项目名称:pylot,代码行数:16,代码来源:gearman_client.py

示例11: GearmanClient

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
#!/usr/bin/env python
import string

from PIL import Image
from gearman import GearmanClient 

gearman_client = GearmanClient(['ftester.chinacloudapp.cn:4730']) 
# gearman_client = GearmanClient(['172.31.1.92:4730']) 

path = './sample_images/tubingen.jpg'
data = open(path, 'rb').read()

ljust = string.ljust('kandinsky_e2_crop512', 100, ' ')
data = ljust + data

gearman_request = gearman_client.submit_job('test', data) 
result_data = gearman_request.result 
with open('test.jpg', 'w+') as pf:
	pf.write(result_data)
	#pf.write(data[10:])
开发者ID:Michael2011,项目名称:code-note,代码行数:22,代码来源:testClient.py

示例12: str

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
    Randomizer function can be changed from client code, for example in order
    to create pseudo-random sequence or something like this
    '''
    return str(delimiter).join([str(randomizer(*randomizer_args)) for x in range(elements)])


# Create object of gearman client for pushing to server node tasks
# Gearman node connection params is taken from general settings module
client = GearmanClient(settings.STUB_GEARMAN_NODES)

while True:
    if random.random() < settings.STUB_TASKS_PROBABILITY.get('reverse', 0.5):
        # Add task for random word reversing
        word = random_word(*settings.STUB_TASKS_ARGS.get('reverse', []))
        client.submit_job('reverse', word, background=True)
        # TODO: logging!
        print 'Add reverse task for <%s>' % word

    if random.random() < settings.STUB_TASKS_PROBABILITY.get('sum', 0.5):
        # Add task for calculating sum of 4 digits
        sum = random_sum(*settings.STUB_TASKS_ARGS.get('sum', []))
        client.submit_job('sum', sum, background=True)
        # TODO: logging!
        print 'Add sum calculation task for <%s>' % sum

    if random.random() < settings.STUB_TASKS_PROBABILITY.get('multiple', 0.5):
        # Add task for calculating multiple of 2 digits
        multiple = random_multiple(*settings.STUB_TASKS_ARGS.get('multiple', []))
        client.submit_job('multiple', multiple, background=True)
        # TODO: logging!
开发者ID:kachayev,项目名称:gearoscope,代码行数:32,代码来源:client.py

示例13: GearmanClient

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
#!/usr/bin/env python2.6
#!/usr/bin/env python2.7
# coding=utf-8
from gearman import GearmanClient

gearman_client = GearmanClient(['127.0.0.1:4730'])

gearman_request = gearman_client.submit_job('echo', 'test gearman')

result_data = gearman_request.result
print result_data
开发者ID:lizhenghn123,项目名称:Gearman_Examples,代码行数:13,代码来源:echo_client.py

示例14: GearmanClient

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 03 16:17:58 2014

@author: jiran
"""

from gearman import GearmanClient
client = GearmanClient(['192.168.1.123:4730'])
request = client.submit_job('reverse','this string')
newresult = request.result
print newresult
开发者ID:EchoSlam,项目名称:Gearman_learn,代码行数:14,代码来源:client.py

示例15: GearmanClient

# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import submit_job [as 别名]
from gearman import GearmanClient
import simplejson
import uuid
import time

# create a client that will connect to the Gearman server running on
# localhost. The array allows you to specify a set of job servers.
client = GearmanClient(['localhost:4730'])

# Submit a synchronous job request to the job server and store the
print 'Sending job...'
build_id = uuid.uuid4().hex
print build_id
jenkins_build_params = {'uuid':build_id,'param2':"true",'param3':'bingo'}
request = client.submit_job('build:durian:oneiric-668621', simplejson.dumps(jenkins_build_params), poll_timeout=60, unique=build_id)

print request.result
print 'Work complete with state %s' % request.state
开发者ID:inthecloud247,项目名称:python-playground,代码行数:20,代码来源:gearman_start_durian.py


注:本文中的gearman.GearmanClient.submit_job方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。