<s> from __future__ import print_function <EOL> import os <EOL> import sys <EOL> if sys . version_info >= ( <NUM_LIT:3> , ) : <EOL> import http . client <EOL> else : <EOL> import httplib <EOL> import mimetypes <EOL> import zipfile <EOL> import time <EOL> from dateutil . tz import * <EOL> import iron_core <EOL> try : <EOL> import json <EOL> except ImportError : <EOL> import simplejson as json <EOL> def file_exists ( file ) : <EOL> """<STR_LIT>""" <EOL> if not os . path . exists ( file ) : <EOL> return False <EOL> try : <EOL> open ( file ) . close ( ) <EOL> except IOError : <EOL> return False <EOL> return True <EOL> class Task : <EOL> id = None <EOL> project = None <EOL> code_id = None <EOL> code_history_id = None <EOL> schedule_id = None <EOL> status = None <EOL> code_name = None <EOL> code_rev = None <EOL> created_at = None <EOL> updated_at = None <EOL> start_time = None <EOL> end_time = None <EOL> duration = None <EOL> timeout = <NUM_LIT> <EOL> message = None <EOL> delay = <NUM_LIT:0> <EOL> start_at = None <EOL> end_at = None <EOL> next_start = None <EOL> last_run_time = None <EOL> run_times = None <EOL> run_count = None <EOL> run_every = None <EOL> percent = None <EOL> payload = None <EOL> priority = <NUM_LIT:0> <EOL> label = None <EOL> cluster = None <EOL> scheduled = False <EOL> repeating = False <EOL> __json_attrs = [ "<STR_LIT>" ] <EOL> __rfc3339_attrs = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] <EOL> __timestamp_attrs = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> __schedule_attrs = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] <EOL> __repeating_attrs = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> __aliases = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:message>" <EOL> } <EOL> __ignore = [ "<STR_LIT:message>" ] <EOL> def __str__ ( self ) : <EOL> if self . id is not None and self . scheduled : <EOL> return "<STR_LIT>" % self . id <EOL> elif self . id is not None : <EOL> return "<STR_LIT>" % self . id <EOL> else : <EOL> return "<STR_LIT>" <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % str ( self ) <EOL> def __set ( self , attr , value ) : <EOL> if attr in self . __rfc3339_attrs : <EOL> if sys . version_info >= ( <NUM_LIT:3> , ) : <EOL> if isinstance ( value , str ) : <EOL> value = iron_core . IronClient . fromRfc3339 ( value ) <EOL> else : <EOL> if isinstance ( value , basestring ) : <EOL> value = iron_core . IronClient . fromRfc3339 ( value ) <EOL> if attr in self . __schedule_attrs : <EOL> self . scheduled = True <EOL> if attr in self . __repeating_attrs : <EOL> self . repeating = True <EOL> if attr in self . __json_attrs : <EOL> try : <EOL> if sys . version_info >= ( <NUM_LIT:3> , ) : <EOL> if isinstance ( value , str ) : <EOL> value = json . loads ( value ) <EOL> else : <EOL> if isinstance ( value , basestring ) : <EOL> value = json . loads ( value ) <EOL> except : <EOL> pass <EOL> setattr ( self , attr , value ) <EOL> def __init__ ( self , values = None , ** kwargs ) : <EOL> if values is None : <EOL> values = { } <EOL> self . payload = { } <EOL> attrs = [ x for x in vars ( self . __class__ ) . keys ( ) <EOL> if not x . startswith ( "<STR_LIT>" ) ] <EOL> for k in kwargs . keys ( ) : <EOL> values [ k ] = kwargs [ k ] <EOL> for prop in values . keys ( ) : <EOL> if prop in attrs and prop not in self . __ignore : <EOL> self . __set ( prop , values [ prop ] ) <EOL> elif prop in self . __aliases : <EOL> self . __set ( self . __aliases [ prop ] , values [ prop ] ) <EOL> class CodePackage : <EOL> id = None <EOL> project = None <EOL> name = None <EOL> runtime = None <EOL> latest_checksum = None <EOL> revision = None <EOL> latest_history_id = None <EOL> latest_change = None <EOL> files = None <EOL> executable = None <EOL> zip_path = None <EOL> __rfc3339_attrs = [ "<STR_LIT>" ] <EOL> __aliases = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> def __str__ ( self ) : <EOL> if self . name is not None : <EOL> return "<STR_LIT>" % self . name <EOL> elif self . id is not None : <EOL> return "<STR_LIT>" % self . id <EOL> else : <EOL> return "<STR_LIT>" <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % str ( self ) <EOL> def __set ( self , attr , value ) : <EOL> if attr in self . __rfc3339_attrs : <EOL> value = iron_core . IronClient . fromRfc3339 ( value ) <EOL> setattr ( self , attr , value ) <EOL> def __init__ ( self , values = None , ** kwargs ) : <EOL> if values is None : <EOL> values = { } <EOL> self . files = { } <EOL> for k in kwargs . keys ( ) : <EOL> values [ k ] = kwargs [ k ] <EOL> attrs = [ x for x in vars ( self . __class__ ) . keys ( ) <EOL> if not x . startswith ( "<STR_LIT>" ) ] <EOL> for prop in values . keys ( ) : <EOL> if prop in attrs : <EOL> self . __set ( prop , values [ prop ] ) <EOL> elif prop in self . __aliases : <EOL> self . __set ( self . __aliases [ prop ] , values [ prop ] ) <EOL> def merge ( self , target , ignoreRootDir = False ) : <EOL> if os . path . isfile ( target ) : <EOL> self . files [ os . path . basename ( target ) ] = target <EOL> elif os . path . isdir ( target ) : <EOL> for dirname , dirnames , filenames in os . walk ( target ) : <EOL> for filename in filenames : <EOL> path = os . path . join ( dirname , filename ) <EOL> if ignoreRootDir : <EOL> ziploc = path . lstrip ( target ) . lstrip ( "<STR_LIT:/>" ) <EOL> else : <EOL> ziploc = path <EOL> self . files [ ziploc ] = path <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" % target ) <EOL> if len ( self . files ) == <NUM_LIT:1> : <EOL> for dest , loc in self . files . items ( ) : <EOL> self . executable = dest <EOL> def merge_dependency ( self , dep ) : <EOL> dependency = __import__ ( dep ) <EOL> location = os . path . dirname ( dependency . __file__ ) <EOL> sys . stdout . write ( str ( location ) ) <EOL> parent = location . rstrip ( os . path . basename ( location ) ) <EOL> sys . stdout . write ( str ( parent ) ) <EOL> for dirname , dirnames , filenames in os . walk ( location ) : <EOL> for filename in filenames : <EOL> path = os . path . join ( dirname , filename ) <EOL> if path . startswith ( parent ) : <EOL> newpath = path [ len ( parent ) : ] <EOL> else : <EOL> newpath = path <EOL> ziploc = newpath . lstrip ( "<STR_LIT:/>" ) <EOL> self . files [ ziploc ] = path <EOL> def zip ( self , destination = None , overwrite = True ) : <EOL> if destination is None : <EOL> if self . name is not None : <EOL> destination = "<STR_LIT>" % self . name <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if file_exists ( destination ) and not overwrite : <EOL> raise ValueError ( "<STR_LIT>" % destination ) <EOL> filelist = self . files . copy ( ) <EOL> for dest , loc in filelist . items ( ) : <EOL> if not file_exists ( loc ) : <EOL> del ( self . files [ dest ] ) <EOL> if len ( self . files ) > <NUM_LIT:0> : <EOL> z = zipfile . ZipFile ( destination , "<STR_LIT:w>" ) <EOL> for dest , loc in self . files . items ( ) : <EOL> z . write ( loc , dest ) <EOL> z . close ( ) <EOL> self . zip_path = destination <EOL> return file_exists ( destination ) <EOL> class IronWorker : <EOL> NAME = "<STR_LIT>" <EOL> VERSION = "<STR_LIT>" <EOL> isLoaded = False <EOL> arguments = { '<STR_LIT>' : None , '<STR_LIT>' : None , '<STR_LIT>' : None , '<STR_LIT>' : None } <EOL> def __init__ ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . client = iron_core . IronClient ( name = IronWorker . NAME , <EOL> version = IronWorker . VERSION , product = "<STR_LIT>" , ** kwargs ) <EOL> def codes ( self ) : <EOL> packages = [ ] <EOL> resp = self . client . get ( "<STR_LIT>" ) <EOL> raw_packages = resp [ "<STR_LIT:body>" ] [ "<STR_LIT>" ] <EOL> for package in raw_packages : <EOL> packages . append ( CodePackage ( package ) ) <EOL> return packages <EOL> def code ( self , id ) : <EOL> if isinstance ( id , CodePackage ) : <EOL> id = id . id <EOL> resp = self . client . get ( "<STR_LIT>" % id ) <EOL> raw_package = resp [ "<STR_LIT:body>" ] <EOL> return CodePackage ( raw_package ) <EOL> def postCode ( self , code , zipFilename = None ) : <EOL> zip_loc = code . zip_path <EOL> if zipFilename is not None : <EOL> zip_loc = zipFilename <EOL> if zip_loc is None : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if not file_exists ( zip_loc ) : <EOL> raise ValueError ( "<STR_LIT>" % zip_loc ) <EOL> if code . name is None : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if code . executable is None : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if code . runtime is None : <EOL> code . runtime = "<STR_LIT>" <EOL> file = open ( zip_loc , "<STR_LIT:rb>" ) <EOL> file_contents = file . read ( ) <EOL> file . close ( ) <EOL> data = [ ( "<STR_LIT:data>" , json . dumps ( { <EOL> "<STR_LIT:name>" : code . name , <EOL> "<STR_LIT>" : code . runtime , <EOL> "<STR_LIT>" : code . executable <EOL> } ) ) ] <EOL> files = [ ( "<STR_LIT:file>" , zip_loc , file_contents ) ] <EOL> content_type , body = IronWorker . encode_multipart_formdata ( data , files ) <EOL> headers = { <EOL> "<STR_LIT:Content-Type>" : content_type <EOL> } <EOL> resp = self . client . post ( url = "<STR_LIT>" , body = body , headers = headers ) <EOL> return CodePackage ( resp [ "<STR_LIT:body>" ] ) <EOL> def upload ( self , target , name = None , executable = None , overwrite = True ) : <EOL> if isinstance ( target , CodePackage ) : <EOL> code = target <EOL> else : <EOL> code = CodePackage ( ) <EOL> code . merge ( target ) <EOL> if name is not None : <EOL> code . name = name <EOL> if executable is not None : <EOL> code . executable = executable <EOL> if code . name is None : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if code . executable is None : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> clean_up = not file_exists ( "<STR_LIT>" % code . name ) or overwrite <EOL> if code . zip_path is None or not file_exists ( code . zip_path ) : <EOL> code . zip ( overwrite = overwrite ) <EOL> result = self . postCode ( code ) <EOL> if clean_up : <EOL> os . remove ( code . zip_path ) <EOL> return result <EOL> def deleteCode ( self , id ) : <EOL> if isinstance ( id , CodePackage ) : <EOL> id = id . id <EOL> resp = self . client . delete ( "<STR_LIT>" % id ) <EOL> return True <EOL> def revisions ( self , id ) : <EOL> revisions = [ ] <EOL> if isinstance ( id , CodePackage ) : <EOL> id = id . id <EOL> resp = self . client . get ( "<STR_LIT>" % id ) <EOL> raw_revs = resp [ "<STR_LIT:body>" ] [ "<STR_LIT>" ] <EOL> for rev in raw_revs : <EOL> revisions . append ( CodePackage ( rev ) ) <EOL> return revisions <EOL> def download ( self , id , rev = None , destination = None ) : <EOL> if isinstance ( id , CodePackage ) : <EOL> if rev is None and id . revision is not None : <EOL> rev = id . revision <EOL> id = id . id <EOL> url = "<STR_LIT>" % id <EOL> if rev is not None : <EOL> url = "<STR_LIT>" % ( url , rev ) <EOL> resp = self . client . get ( url ) <EOL> dest = resp [ "<STR_LIT>" ] . getheader ( "<STR_LIT>" ) <EOL> dest = dest . lstrip ( "<STR_LIT>" ) <EOL> if destination is not None : <EOL> if os . path . isdir ( destination ) : <EOL> dest = os . path . join ( destination , dest ) <EOL> else : <EOL> dest = destination <EOL> dup_dest = dest <EOL> iteration = <NUM_LIT:1> <EOL> while file_exists ( dup_dest ) and destination is None : <EOL> iteration += <NUM_LIT:1> <EOL> dup_dest = dest . rstrip ( "<STR_LIT>" ) + "<STR_LIT>" + str ( iteration ) + "<STR_LIT>" <EOL> f = open ( dup_dest , "<STR_LIT:wb>" ) <EOL> f . write ( resp [ "<STR_LIT:body>" ] ) <EOL> f . close ( ) <EOL> return file_exists ( dup_dest ) <EOL> def tasks ( self , scheduled = False , page = None , per_page = <NUM_LIT:30> , ** kwargs ) : <EOL> query_params = [ ] <EOL> if page : <EOL> query_params . append ( "<STR_LIT>" % page ) <EOL> if per_page > <NUM_LIT:100> : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> elif per_page : <EOL> query_params . append ( '<STR_LIT>' % per_page ) <EOL> if not scheduled : <EOL> if '<STR_LIT>' in kwargs : <EOL> query_params . append ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in kwargs : <EOL> query_params . append ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in kwargs : <EOL> query_params . append ( '<STR_LIT>' ) <EOL> if '<STR_LIT:error>' in kwargs : <EOL> query_params . append ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in kwargs : <EOL> query_params . append ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in kwargs : <EOL> query_params . append ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in kwargs : <EOL> query_params . append ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in kwargs : <EOL> if not ( isinstance ( kwargs [ '<STR_LIT>' ] , int ) ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> query_params . append ( '<STR_LIT>' % kwargs [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in kwargs : <EOL> if not ( isinstance ( kwargs [ '<STR_LIT>' ] , int ) ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> query_params . append ( '<STR_LIT>' % kwargs [ '<STR_LIT>' ] ) <EOL> query_params = "<STR_LIT:&>" . join ( query_params ) <EOL> request_string = "<STR_LIT>" + query_params <EOL> resp = self . client . get ( request_string ) <EOL> raw_tasks = resp [ "<STR_LIT:body>" ] <EOL> raw_tasks = raw_tasks [ "<STR_LIT>" ] <EOL> else : <EOL> query_params = "<STR_LIT:&>" . join ( query_params ) <EOL> request_string = "<STR_LIT>" + query_params <EOL> resp = self . client . get ( request_string ) <EOL> raw_tasks = resp [ "<STR_LIT:body>" ] <EOL> raw_tasks = raw_tasks [ "<STR_LIT>" ] <EOL> tasks = [ Task ( raw_task ) for raw_task in raw_tasks ] <EOL> return tasks <EOL> def tasks_by_code_name ( self , code_name ) : <EOL> tasks = [ ] <EOL> resp = self . client . get ( "<STR_LIT>" % code_name ) <EOL> raw_tasks = resp [ "<STR_LIT:body>" ] [ "<STR_LIT>" ] <EOL> for raw_task in raw_tasks : <EOL> tasks . append ( Task ( raw_task ) ) <EOL> return tasks <EOL> def queue ( self , task = None , tasks = None , retry = None , ** kwargs ) : <EOL> tasks_data = [ ] <EOL> if task is None : <EOL> task = Task ( ** kwargs ) <EOL> if tasks is None : <EOL> tasks = [ task ] <EOL> for task in tasks : <EOL> payload = task . payload <EOL> if sys . version_info >= ( <NUM_LIT:3> , ) : <EOL> if not isinstance ( payload , str ) : <EOL> payload = json . dumps ( payload ) <EOL> else : <EOL> if not isinstance ( payload , basestring ) : <EOL> payload = json . dumps ( payload ) <EOL> if task . code_name is None : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> task_data = { <EOL> "<STR_LIT:name>" : task . code_name , <EOL> "<STR_LIT>" : task . code_name , <EOL> "<STR_LIT>" : payload , <EOL> "<STR_LIT>" : task . priority , <EOL> "<STR_LIT>" : task . delay , <EOL> "<STR_LIT:label>" : task . label , <EOL> "<STR_LIT>" : task . cluster <EOL> } <EOL> if not task . scheduled : <EOL> type_str = "<STR_LIT>" <EOL> task_data [ "<STR_LIT>" ] = task . timeout <EOL> else : <EOL> type_str = "<STR_LIT>" <EOL> if task . run_every is not None : <EOL> task_data [ "<STR_LIT>" ] = task . run_every <EOL> if task . end_at is not None : <EOL> if task . end_at . tzinfo is None : <EOL> task . end_at = task . end_at . replace ( tzinfo = tzlocal ( ) ) <EOL> task_data [ "<STR_LIT>" ] = iron_core . IronClient . toRfc3339 ( <EOL> task . end_at ) <EOL> if task . run_times is not None : <EOL> task_data [ "<STR_LIT>" ] = task . run_times <EOL> if task . start_at is not None : <EOL> if task . start_at . tzinfo is None : <EOL> task . start_at = task . start_at . replace ( tzinfo = tzlocal ( ) ) <EOL> task_data [ "<STR_LIT>" ] = iron_core . IronClient . toRfc3339 ( <EOL> task . start_at ) <EOL> if task . timeout is not None : <EOL> task_data [ "<STR_LIT>" ] = task . timeout <EOL> task_data [ "<STR_LIT:label>" ] = task . label <EOL> task_data [ "<STR_LIT>" ] = task . cluster <EOL> tasks_data . append ( task_data ) <EOL> data = json . dumps ( { type_str : tasks_data } ) <EOL> headers = { "<STR_LIT:Content-Type>" : "<STR_LIT:application/json>" } <EOL> if retry is not None : <EOL> resp = self . client . post ( type_str , body = data , headers = headers , retry = retry ) <EOL> else : <EOL> resp = self . client . post ( type_str , body = data , headers = headers ) <EOL> tasks = resp [ "<STR_LIT:body>" ] <EOL> if len ( tasks [ type_str ] ) > <NUM_LIT:1> : <EOL> return [ Task ( task , scheduled = ( type_str == "<STR_LIT>" ) ) <EOL> for task in tasks [ type_str ] ] <EOL> else : <EOL> return Task ( tasks [ type_str ] [ <NUM_LIT:0> ] , <EOL> scheduled = ( type_str == "<STR_LIT>" ) ) <EOL> def task ( self , id , scheduled = False ) : <EOL> if isinstance ( id , Task ) : <EOL> scheduled = id . scheduled <EOL> id = id . id <EOL> if not scheduled : <EOL> url = "<STR_LIT>" % id <EOL> else : <EOL> url = "<STR_LIT>" % id <EOL> resp = self . client . get ( url ) <EOL> raw_task = resp [ "<STR_LIT:body>" ] <EOL> return Task ( raw_task ) <EOL> def log ( self , id ) : <EOL> if isinstance ( id , Task ) : <EOL> if id . scheduled : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> id = id . id <EOL> url = "<STR_LIT>" % id <EOL> headers = { "<STR_LIT>" : "<STR_LIT>" } <EOL> resp = self . client . get ( url , headers = headers ) <EOL> return resp [ "<STR_LIT:body>" ] <EOL> def setProgress ( self , id , percent , msg = '<STR_LIT>' ) : <EOL> if isinstance ( id , Task ) : <EOL> id = id . id <EOL> url = "<STR_LIT>" % id <EOL> body = { } <EOL> body [ '<STR_LIT>' ] = percent <EOL> body [ '<STR_LIT>' ] = msg <EOL> body = json . dumps ( body ) <EOL> resp = self . client . post ( url , body = body , <EOL> headers = { "<STR_LIT:Content-Type>" : "<STR_LIT:application/json>" } ) <EOL> return resp [ "<STR_LIT:body>" ] <EOL> def retry ( self , id , delay = <NUM_LIT:1> ) : <EOL> if isinstance ( id , Task ) : <EOL> id = id . id <EOL> url = "<STR_LIT>" % id <EOL> body = { } <EOL> body [ '<STR_LIT>' ] = delay <EOL> body = json . dumps ( body ) <EOL> resp = self . client . post ( url , body = body , <EOL> headers = { "<STR_LIT:Content-Type>" : "<STR_LIT:application/json>" } ) <EOL> return resp [ "<STR_LIT:body>" ] <EOL> def cancel ( self , id , scheduled = False ) : <EOL> if isinstance ( id , Task ) : <EOL> scheduled = id . scheduled <EOL> id = id . id <EOL> if not scheduled : <EOL> url = "<STR_LIT>" % id <EOL> else : <EOL> url = "<STR_LIT>" % id <EOL> resp = self . client . post ( url ) <EOL> return True <EOL> @ staticmethod <EOL> def encode_multipart_formdata ( fields , files ) : <EOL> """<STR_LIT>""" <EOL> BOUNDARY = '<STR_LIT>' <EOL> CRLF = '<STR_LIT:\r\n>' <EOL> L = [ ] <EOL> for ( key , value ) in fields : <EOL> L . append ( '<STR_LIT>' + BOUNDARY ) <EOL> L . append ( '<STR_LIT>' % key ) <EOL> L . append ( '<STR_LIT>' ) <EOL> L . append ( str ( value ) ) <EOL> for ( key , filename , value ) in files : <EOL> L . append ( '<STR_LIT>' + BOUNDARY ) <EOL> L . append ( '<STR_LIT>' <EOL> % ( key , filename ) ) <EOL> L . append ( '<STR_LIT>' <EOL> % IronWorker . get_content_type ( filename ) ) <EOL> L . append ( '<STR_LIT>' ) <EOL> L . append ( str ( value ) ) <EOL> L . append ( '<STR_LIT>' + BOUNDARY + '<STR_LIT>' ) <EOL> L . append ( '<STR_LIT>' ) <EOL> body = CRLF . join ( L ) <EOL> content_type = '<STR_LIT>' % BOUNDARY <EOL> return content_type , str ( body ) <EOL> @ staticmethod <EOL> def get_content_type ( filename ) : <EOL> return mimetypes . guess_type ( filename ) [ <NUM_LIT:0> ] or '<STR_LIT>' <EOL> @ staticmethod <EOL> def load_args ( ) : <EOL> if IronWorker . isLoaded : return <EOL> for i in range ( len ( sys . argv ) ) : <EOL> if sys . argv [ i ] == "<STR_LIT>" : <EOL> IronWorker . arguments [ '<STR_LIT>' ] = sys . argv [ i + <NUM_LIT:1> ] <EOL> if sys . argv [ i ] == "<STR_LIT>" : <EOL> IronWorker . arguments [ '<STR_LIT>' ] = sys . argv [ i + <NUM_LIT:1> ] <EOL> if sys . argv [ i ] == "<STR_LIT>" : <EOL> IronWorker . arguments [ '<STR_LIT>' ] = sys . argv [ i + <NUM_LIT:1> ] <EOL> if sys . argv [ i ] == "<STR_LIT>" : <EOL> IronWorker . arguments [ '<STR_LIT>' ] = sys . argv [ i + <NUM_LIT:1> ] <EOL> if os . getenv ( '<STR_LIT>' ) : IronWorker . arguments [ '<STR_LIT>' ] = os . getenv ( '<STR_LIT>' ) <EOL> if os . getenv ( '<STR_LIT>' ) : IronWorker . arguments [ '<STR_LIT>' ] = os . getenv ( '<STR_LIT>' ) <EOL> if os . getenv ( '<STR_LIT>' ) : IronWorker . arguments [ '<STR_LIT>' ] = os . getenv ( '<STR_LIT>' ) <EOL> if os . getenv ( '<STR_LIT>' ) : IronWorker . arguments [ '<STR_LIT>' ] = os . getenv ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in IronWorker . arguments and file_exists ( IronWorker . arguments [ '<STR_LIT>' ] ) : <EOL> f = open ( IronWorker . arguments [ '<STR_LIT>' ] , "<STR_LIT:r>" ) <EOL> try : <EOL> content = f . read ( ) <EOL> f . close ( ) <EOL> IronWorker . arguments [ '<STR_LIT>' ] = json . loads ( content ) <EOL> except Exception as e : <EOL> print ( "<STR_LIT>" % e ) <EOL> if '<STR_LIT>' in IronWorker . arguments and file_exists ( IronWorker . arguments [ '<STR_LIT>' ] ) : <EOL> f = open ( IronWorker . arguments [ '<STR_LIT>' ] ) <EOL> try : <EOL> content = f . read ( ) <EOL> f . close ( ) <EOL> IronWorker . arguments [ '<STR_LIT>' ] = json . loads ( content ) <EOL> except Exception as e : <EOL> print ( "<STR_LIT>" % e ) <EOL> IronWorker . isLoaded = True <EOL> @ staticmethod <EOL> def payload ( ) : <EOL> IronWorker . load_args ( ) <EOL> return IronWorker . arguments [ '<STR_LIT>' ] <EOL> @ staticmethod <EOL> def config ( ) : <EOL> IronWorker . load_args ( ) <EOL> return IronWorker . arguments [ '<STR_LIT>' ] <EOL> @ staticmethod <EOL> def task_id ( ) : <EOL> IronWorker . load_args ( ) <EOL> return IronWorker . arguments [ '<STR_LIT>' ] <EOL> @ staticmethod <EOL> def task_dir ( ) : <EOL> IronWorker . load_args ( ) <EOL> return IronWorker . arguments [ '<STR_LIT>' ] <EOL> @ staticmethod <EOL> def args ( ) : <EOL> IronWorker . load_args ( ) <EOL> return IronWorker . arguments <EOL> @ staticmethod <EOL> def loaded ( ) : <EOL> return IronWorker . isLoaded </s>
