<s> import logging <EOL> import requests <EOL> import json <EOL> import os <EOL> url = "<STR_LIT>" <EOL> headers = { '<STR_LIT>' : '<STR_LIT:application/json>' } <EOL> id_val = <NUM_LIT:0> <EOL> req_id = None <EOL> class Service : <EOL> def __init__ ( self ) : <EOL> pass <EOL> def shutdown ( self ) : <EOL> pass <EOL> def preBatch ( self ) : <EOL> pass <EOL> def postBatch ( self ) : <EOL> pass <EOL> def preRequest ( self ) : <EOL> pass <EOL> def postRequest ( self ) : <EOL> pass <EOL> class ServiceError ( Exception ) : <EOL> def __init__ ( self , msg , data = None ) : <EOL> self . msg = msg <EOL> self . data = data <EOL> def make_call ( method , * _params ) : <EOL> global id_val <EOL> global req_id <EOL> params = list ( _params ) <EOL> params . insert ( <NUM_LIT:0> , req_id ) <EOL> payload = { <EOL> '<STR_LIT>' : method , <EOL> '<STR_LIT>' : params , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:id>' : id_val , <EOL> } <EOL> response = requests . post ( url , data = json . dumps ( payload ) , headers = headers ) . json ( ) <EOL> id_val += <NUM_LIT:1> <EOL> if '<STR_LIT:result>' in response : <EOL> return response [ '<STR_LIT:result>' ] <EOL> else : <EOL> raise RuntimeError ( response [ '<STR_LIT:error>' ] ) <EOL> root_dir = os . getcwd ( ) <EOL> in_container = True if os . path . exists ( '<STR_LIT>' ) else False <EOL> def get_stackhut_user ( ) : <EOL> return make_call ( '<STR_LIT>' ) <EOL> def get_service_author ( ) : <EOL> return make_call ( '<STR_LIT>' ) <EOL> def is_author ( ) : <EOL> return make_call ( '<STR_LIT>' ) <EOL> def put_file ( fname , make_public = True ) : <EOL> return make_call ( '<STR_LIT>' , fname , make_public ) <EOL> def get_file ( key ) : <EOL> return make_call ( '<STR_LIT>' , key ) <EOL> def download_file ( url , fname = None ) : <EOL> return make_call ( '<STR_LIT>' , url , fname ) <EOL> def run_command ( cmd , stdin = '<STR_LIT>' ) : <EOL> return make_call ( '<STR_LIT>' , cmd ) </s>
