<s> import py <EOL> class XSpec : <EOL> """<STR_LIT>""" <EOL> popen = ssh = socket = python = chdir = nice = None <EOL> def __init__ ( self , string ) : <EOL> self . _spec = string <EOL> for keyvalue in string . split ( "<STR_LIT>" ) : <EOL> i = keyvalue . find ( "<STR_LIT:=>" ) <EOL> if i == - <NUM_LIT:1> : <EOL> key , value = keyvalue , True <EOL> else : <EOL> key , value = keyvalue [ : i ] , keyvalue [ i + <NUM_LIT:1> : ] <EOL> if key not in XSpec . __dict__ : <EOL> raise AttributeError ( "<STR_LIT>" % key ) <EOL> setattr ( self , key , value ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . _spec , ) <EOL> def __str__ ( self ) : <EOL> return self . _spec <EOL> def __hash__ ( self ) : <EOL> return hash ( self . _spec ) <EOL> def __eq__ ( self , other ) : <EOL> return self . _spec == getattr ( other , '<STR_LIT>' , None ) <EOL> def __ne__ ( self , other ) : <EOL> return self . _spec != getattr ( other , '<STR_LIT>' , None ) <EOL> def _samefilesystem ( self ) : <EOL> return bool ( self . popen and not self . chdir ) <EOL> def makegateway ( spec ) : <EOL> if not isinstance ( spec , XSpec ) : <EOL> spec = XSpec ( spec ) <EOL> if spec . popen : <EOL> gw = py . execnet . PopenGateway ( python = spec . python ) <EOL> elif spec . ssh : <EOL> gw = py . execnet . SshGateway ( spec . ssh , remotepython = spec . python ) <EOL> elif spec . socket : <EOL> assert not spec . python , "<STR_LIT>" <EOL> hostport = spec . socket . split ( "<STR_LIT::>" ) <EOL> gw = py . execnet . SocketGateway ( * hostport ) <EOL> gw . spec = spec <EOL> if spec . chdir or spec . nice : <EOL> channel = gw . remote_exec ( """<STR_LIT>""" ) <EOL> nice = spec . nice and int ( spec . nice ) or <NUM_LIT:0> <EOL> channel . send ( ( spec . chdir , nice ) ) <EOL> channel . waitclose ( ) <EOL> return gw </s>
