def __init__(self, handle): """ Performs setup, and runs the specified activity. """ self.log = logging.getLogger('sugarbot') # Set up threading... gtk.gdk.threads_init() # Handle is set to 'None' for testing purposes via Nose. Obviously, # if Sugar sets the handle to None, there are other problems... if handle is None: return try: # Create the RPC connection object self.__xmlRPC = ServerProxy(proxyString()) # Set up the sbGUI object for automation self.__sbgui = sbGUI(self, self.__xmlRPC) # Get our activity name activityName = self.__initializeScript() # Actually clone the activity self.__selectActivity(activityName) self.__dynamicImport(self.__importClass,self.__path) self.__cloneActivity(handle) except socket.error: sys.log.error("====== COULD NOT CONNECT TO XML-RPC SERVER ======") sys.exit(-1)
def connectToXMLRPC(self): """ Connects to the ML-RPC server, tests connectivity. """ xml = ServerProxy(proxyString()) try: xml.testConnectivity() except: logging.fatal('Could not connect to the XML-RPC server') sys.exit(1) return xml
def __init__(self): # Set the environment variable to emulate, and the executed scripts. os.environ['SUGARBOT_EMULATOR']='1' # Get the connection to the XML-RPC server self.xml = self.connectToXMLRPC() logging.info("Connected to XML-RPC server %s" % proxyString()) # Get our ID and reset the state self.ID = self.getSugarbotClientID() self.xml.resetClientState(self.ID) logging.info("Using session ID %s" % self.ID)
def __init__(self, shell, shellModel): gtk.gdk.event_handler_set(self.eventHandler) self.model = shellModel self.numberOfScripts = 0 self.shell = shell self.sugarbotIsRunning = False self.timesLaunched = 0 self.xml = ServerProxy(proxyString()) home = self.model.get_home() home.connect('activity-started', self._activity_started_cb) home.connect('activity-removed', self._activity_removed_cb) home.connect('active-activity-changed', self._activity_active_cb) home.connect('pending-activity-changed', self._activity_pending_cb)