<s> import gear <EOL> import json <EOL> import time <EOL> import uuid <EOL> class FakeJob ( object ) : <EOL> def __init__ ( self ) : <EOL> pass <EOL> def sendWorkStatus ( self , * args , ** kwargs ) : <EOL> pass <EOL> class FakeZuul ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , server , port ) : <EOL> self . gearman = gear . Client ( '<STR_LIT>' ) <EOL> self . gearman . addServer ( server , port ) <EOL> self . gearman . waitForServer ( ) <EOL> self . job = None <EOL> def make_zuul_data ( self , data = { } ) : <EOL> job_uuid = str ( uuid . uuid1 ( ) ) <EOL> defaults = { <EOL> '<STR_LIT>' : job_uuid , <EOL> '<STR_LIT>' : '<STR_LIT:a>' , <EOL> '<STR_LIT>' : '<STR_LIT:a>' , <EOL> '<STR_LIT>' : '<STR_LIT:a>' , <EOL> '<STR_LIT>' : '<STR_LIT:a>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' % job_uuid <EOL> } <EOL> defaults . update ( data ) <EOL> return defaults <EOL> def submit_job ( self , name , data ) : <EOL> if not self . job : <EOL> self . job = gear . Job ( name , <EOL> json . dumps ( data ) , <EOL> unique = str ( time . time ( ) ) ) <EOL> self . gearman . submitJob ( self . job ) <EOL> else : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> return self . job <EOL> def wait_for_completion ( self ) : <EOL> if self . job : <EOL> while not self . job . complete : <EOL> time . sleep ( <NUM_LIT:0.1> ) </s>
