<s> """<STR_LIT>""" <EOL> try : <EOL> import anyjson <EOL> except ImportError : <EOL> try : <EOL> import simplejson as json <EOL> except ImportError : <EOL> import json <EOL> class anyjson ( object ) : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def serialize ( buf ) : <EOL> return json . dumps ( buf ) <EOL> @ staticmethod <EOL> def deserialize ( buf ) : <EOL> return json . loads ( buf ) <EOL> import os <EOL> import platform <EOL> import pyxenstore <EOL> XENSTORE_INTERFACE_PATH = "<STR_LIT>" <EOL> XENSTORE_HOSTNAME_PATH = "<STR_LIT>" <EOL> XENSTORE_VIRT_PROVIDER = "<STR_LIT>" <EOL> XENSTORE_USER_METADATA = "<STR_LIT>" <EOL> XENSTORE_AUTO_DISK_CONFIG = "<STR_LIT>" <EOL> DEFAULT_HOSTNAME = '<STR_LIT>' <EOL> def recon ( ) : <EOL> system = os . uname ( ) [ <NUM_LIT:0> ] <EOL> if system == "<STR_LIT>" : <EOL> system = platform . linux_distribution ( full_distribution_name = <NUM_LIT:0> ) [ <NUM_LIT:0> ] <EOL> if not system and os . path . exists ( '<STR_LIT>' ) : <EOL> system = '<STR_LIT>' <EOL> if not system : <EOL> return None <EOL> system = system . lower ( ) <EOL> global DEFAULT_HOSTNAME <EOL> DEFAULT_HOSTNAME = system <EOL> def read_xenstore ( ) : <EOL> recon ( ) <EOL> xs_handle = pyxenstore . Handle ( ) <EOL> try : <EOL> hostname = xs_handle . read ( XENSTORE_HOSTNAME_PATH ) <EOL> print ( '<STR_LIT>' % hostname ) <EOL> except pyxenstore . NotFoundError : <EOL> hostname = DEFAULT_HOSTNAME <EOL> print ( '<STR_LIT>' % hostname ) <EOL> interfaces = [ ] <EOL> try : <EOL> entries = xs_handle . entries ( XENSTORE_INTERFACE_PATH ) <EOL> except pyxenstore . NotFoundError : <EOL> entries = [ ] <EOL> for entry in entries : <EOL> data = xs_handle . read ( XENSTORE_INTERFACE_PATH + '<STR_LIT:/>' + entry ) <EOL> data = anyjson . deserialize ( data ) <EOL> interfaces . append ( data ) <EOL> print ( '<STR_LIT>' % ( entry , data ) ) <EOL> del xs_handle <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> read_xenstore ( ) </s>
