<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from vistrails . core import debug <EOL> import vistrails . core . system <EOL> import os <EOL> import platform <EOL> import sys <EOL> def guess_graphical_sudo ( ) : <EOL> """<STR_LIT>""" <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> return '<STR_LIT:%s>' , False <EOL> if vistrails . core . system . executable_is_in_path ( '<STR_LIT>' ) : <EOL> return '<STR_LIT>' , True <EOL> elif vistrails . core . system . executable_is_in_path ( '<STR_LIT>' ) : <EOL> return '<STR_LIT>' , False <EOL> elif vistrails . core . system . executable_is_in_path ( '<STR_LIT>' ) : <EOL> return '<STR_LIT>' , False <EOL> elif ( vistrails . core . system . executable_is_in_path ( '<STR_LIT>' ) and <EOL> vistrails . core . system . executable_is_in_path ( '<STR_LIT>' ) ) : <EOL> return ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> False ) <EOL> elif vistrails . core . system . executable_is_in_path ( '<STR_LIT>' ) : <EOL> return "<STR_LIT>" "<STR_LIT>" , True <EOL> else : <EOL> debug . warning ( "<STR_LIT>" ) <EOL> if vistrails . core . system . executable_is_in_path ( '<STR_LIT>' ) : <EOL> debug . warning ( "<STR_LIT>" ) <EOL> return "<STR_LIT>" , False <EOL> else : <EOL> debug . warning ( "<STR_LIT>" ) <EOL> return "<STR_LIT>" , True <EOL> class System_guesser ( object ) : <EOL> def __init__ ( self ) : <EOL> self . _callable_dict = { } <EOL> def add_test ( self , test , system_name ) : <EOL> if self . _callable_dict . has_key ( system_name ) : <EOL> raise ValueError ( "<STR_LIT>" % system_name ) <EOL> if system_name == '<STR_LIT>' : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> assert isinstance ( system_name , str ) <EOL> self . _callable_dict [ system_name ] = test <EOL> def guess_system ( self ) : <EOL> for ( name , callable_ ) in self . _callable_dict . iteritems ( ) : <EOL> if callable_ ( ) : <EOL> return name <EOL> else : <EOL> return '<STR_LIT>' <EOL> _system_guesser = System_guesser ( ) <EOL> def _guess_suse ( ) : <EOL> try : <EOL> tokens = open ( '<STR_LIT>' ) . readline ( ) [ - <NUM_LIT:1> ] . split ( ) <EOL> return tokens [ <NUM_LIT:0> ] == '<STR_LIT>' <EOL> except ( IOError , IndexError ) : <EOL> return False <EOL> _system_guesser . add_test ( _guess_suse , '<STR_LIT>' ) <EOL> def _guess_ubuntu ( ) : <EOL> return platform . linux_distribution ( ) [ <NUM_LIT:0> ] == '<STR_LIT>' or platform . linux_distribution ( ) [ <NUM_LIT:0> ] == '<STR_LIT>' <EOL> _system_guesser . add_test ( _guess_ubuntu , '<STR_LIT>' ) <EOL> def _guess_debian ( ) : <EOL> return platform . linux_distribution ( ) [ <NUM_LIT:0> ] . lower ( ) == '<STR_LIT>' <EOL> _system_guesser . add_test ( _guess_debian , '<STR_LIT>' ) <EOL> def _guess_fedora ( ) : <EOL> return os . path . isfile ( '<STR_LIT>' ) <EOL> _system_guesser . add_test ( _guess_fedora , '<STR_LIT>' ) <EOL> def _guess_windows ( ) : <EOL> return vistrails . core . system . systemType == '<STR_LIT>' <EOL> _system_guesser . add_test ( _guess_windows , '<STR_LIT>' ) <EOL> def guess_system ( ) : <EOL> """<STR_LIT>""" <EOL> return _system_guesser . guess_system ( ) </s>
