Beispiel #1
0
    def __init__(self, url):
        VenueClient.__init__(self)
        print '--------------- SET PROFILE'
        profile = ClientProfile('userProfile')
        self.SetProfile(profile)
        self.profile.Dump()

        print '\n--------------- CREATE PROXY'
        try:
            venueUri = Client.Handle(url).get_proxy().GetDefaultVenue()
            print 'get url for default venue from server ', url

        except:
            venueUri = url

        print 'venue url: ', url
        print 'get proxy for venue', venueUri
        self.client = Client.Handle(venueUri).get_proxy()

        print '\n--------------- ENTER VENUE'
        self.EnterVenue(venueUri)

        print '\n--------------- ADD DATA'
        self.upload_url = self.client.GetUploadDescriptor()
        file_list = ['test_Apps.py']
        DataStore.GSIHTTPUploadFiles(self.upload_url, file_list, None)

        print '\n--------------- REMOVE DATA'
        data = DataDescription3('test_Apps.py')
        self.client.RemoveData(data)

        #         print '\n--------------- ADD SERVICE'
        #         service = ServiceDescription('serviceName', 'serviceDescription', 'serviceUri',\
        #                                      'serviceIcon', 'serviceStoragetype')
        #         self.client.AddService(service)

        #         print '\n--------------- REMOVE DATA'
        #        self.client.RemoveData(data)

        #         print '\n--------------- REMOVE SERVICE'
        #         self.client.RemoveService(service)

        nodeUrl = 'http://nodeserviceurl'
        print '\n--------------- SET NODE SERVICE URL', nodeUrl
        self.SetNodeServiceUri(nodeUrl)
        print '--------------- NODE SERVICE URL: ', self.nodeServiceUri

        print '\n--------------- CHANGE PROFILE'
        profile2 = ClientProfile('nodeProfile')
        self.SetProfile(profile2)
        self.profile.Dump()

        print '\n--------------- EXIT VENUE'
        self.ExitVenue()
Beispiel #2
0
    def test_150_SetIdentity(self):

        global nodeService

        profile = ClientProfile(UserConfig.instance().GetProfile())

        nodeService.SetIdentity(profile)
    def LoadPreferences(self):
        '''
        Read preferences from configuration file.
        '''
        try:
            log.debug("Preferences.LoadPreferences: open file")
            preferences = LoadConfig(self.config.GetPreferences())

            # Remove category from preference
            for p in preferences.keys():
                category = p.split(".")[0]
                pref = p.split(".")[1]

                if category == "Preferences":
                    self.preferences[pref] = preferences[p]

            # Add any default preferences that are missing
            for key in self.default:
                if not self.preferences.has_key(key):

                    # set the initial value of the proxy enabled preference based on whether
                    # the user has specified a proxy host previously
                    # note:  this only happens the first time a preferences file is loaded that
                    # is missing the PROXY_ENABLED preference
                    if key == self.PROXY_ENABLED:
                        if self.preferences.has_key(self.PROXY_HOST) and len(
                                self.preferences[self.PROXY_HOST]) > 0:
                            self.preferences[key] = 1
                            continue
                    self.preferences[key] = self.default[key]

        except:
            log.exception("Preferences.LoadPreferences: open file error")
            self.preferences = {}

        # Load client profile separately
        try:
            profileFile = os.path.join(self.config.GetConfigDir(), "profile")
            self.profile = ClientProfile(profileFile)

        except IOError:
            log.exception("Preferences.LoadPreferences: open file io error")

        # Load bridges separately
        for b in self.bridgeCache.GetBridges():
            self.__bridges[b.GetKey()] = b
Beispiel #4
0
def RunClient(*args, **kw):
    m2threading.init()
    id = kw["id"]
    venueUri = kw["url"]
    app = kw["app"]
    iter = app.GetOption("rt")
    verbose = kw["verbose"]

    profile = ClientProfile()
    profile.name = "Test Client %s" % id
    profile.publicId = str(GUID())

    client = MyVenueClient(profile, app)

    for i in range(iter):
        try:
            if verbose:
                print "Entering Venue: %s" % venueUri
            ret = client.EnterVenue(venueUri)
            if ret:
                print "** EnterVenue ret = ", ret
            print "Client %d Entered %s %d times" % (id, venueUri, i)
        except:
            print traceback.print_exc()
            continue

        if verbose:
            client.PrintVenueState()

        # Pick next one
        if client.venueState is not None:
            exits = client.venueState.connections.values()
            if len(exits):
                next_index = random.randint(0, len(exits) - 1)
                venueUri = exits[next_index].uri

        try:
            time.sleep(1)
            client.ExitVenue()
            if verbose:
                print "Exited venue !"
        except:
            print traceback.print_exc()

    client.Shutdown()
    m2threading.cleanup()
def RunClient(*args, **kw):
    m2threading.init()
    id = kw['id']
    venueUri = kw['url']
    app = kw['app']
    iter = app.GetOption("rt")
    verbose = kw['verbose']

    profile = ClientProfile()
    profile.name = "Test Client %s" % id
    profile.publicId = str(GUID())

    client = MyVenueClient(profile, app)
    
    for i in range(iter):
        try:
            if verbose:
                print "Entering Venue: %s" % venueUri
            ret = client.EnterVenue(venueUri)
            if ret:
                print '** EnterVenue ret = ', ret
            print "Client %d Entered %s %d times" % (id, venueUri,i)
        except:
            print traceback.print_exc()
            continue
        
        if verbose:
            client.PrintVenueState()

        # Pick next one
        if client.venueState is not None:
            exits = client.venueState.connections.values()
            if len(exits):
                next_index = random.randint(0, len(exits)-1)
                venueUri = exits[next_index].uri

        try:
            time.sleep(1)
            client.ExitVenue()
            if verbose:
                print "Exited venue !"
        except:
            print traceback.print_exc()

    client.Shutdown()
    m2threading.cleanup()
Beispiel #6
0
    def testSaveLoad(self):
        c = ClientProfile()
        filename = os.path.join(SystemConfig.instance().GetTempDir(),
                                ".testProfile")
        c.Save(filename)

        d = ClientProfile()
        d.Load(filename)
        assert d.CheckProfile()
Beispiel #7
0
    def __init__(self, appUrl, name, size=None):
        '''
        Creates the shared application client, used for
        application service interaction, and opens a web browser
        for UI display.
        '''
        wx.App.__init__(self, False)

        reactor.interleave(wx.CallAfter)
        # Create shared application client
        self.sharedAppClient = SharedAppClient(name)
        self.log = self.sharedAppClient.InitLogging()

        # Get client profile
        try:
            clientProfileFile = os.path.join(
                UserConfig.instance().GetConfigDir(), "profile")
            clientProfile = ClientProfile(clientProfileFile)
        except:
            self.log.info(
                "SharedAppClient.Connect: Could not load client profile, set clientProfile = None"
            )
            clientProfile = None

        # Join the application session.
        self.sharedAppClient.Join(appUrl, clientProfile)

        # Register browse event callback
        self.sharedAppClient.RegisterEventCallback("browse",
                                                   self.BrowseCallback)

        # Create Browser Window
        self.frame = wx.Frame(None, -1, "SharedBrowser", size=size)
        if sys.platform != Platform.WIN:
            self.frame.CreateStatusBar()
        self.browser = WebBrowser(self.frame, -1, self.log, self.frame)

        # Add callback for local browsing
        self.browser.add_navigation_callback(self.IBrowsedCallback)

        # Browse to the current url, if exists
        currentUrl = self.sharedAppClient.GetData("url")

        if currentUrl and len(currentUrl) > 0:
            self.browser.navigate(currentUrl)
            try:
                self.sharedAppClient.SetParticipantStatus(currentUrl)
            except:
                self.log.exception(
                    "SharedBrowser:__init__: Failed to set participant status")

        self.frame.SetIcon(icons.getAGIconIcon())
        self.frame.Show(1)
        self.SetTopWindow(self.frame)
Beispiel #8
0
    def testClientProfile(self):
        def cpEqualityTest(cp1, cp2):
            return cp1.profileType == cp2.profileType and \
                   cp1.name == cp2.name and \
                   cp1.email == cp2.email and \
                   cp1.phoneNumber == cp2.phoneNumber and \
                   cp1.publicId == cp2.publicId and \
                   cp1.location == cp2.location and \
                   cp1.privateId == cp2.privateId and \
                   cp1.distinguishedName == cp2.distinguishedName

        self.generalTest(ClientProfile(), cpEqualityTest)
Beispiel #9
0
    def __init__(self, parent, name, appUrl, venueUrl, connectionId):
        wx.Panel.__init__(self, parent, -1)

        reactor.interleave(wx.CallAfter)
        
        # Create ActiveX interface to adobe acrobate reader
        self.pdf = PDFWindow(self)
        
        # Do UI layout
        self.__Layout()
    
        # Create UI events
        EVT_BUTTON(self, self.openButton.GetId(), self.OnOpenButton)
        EVT_BUTTON(self, self.prevButton.GetId(), self.OnPrevPageButton)
        EVT_BUTTON(self, self.nextButton.GetId(), self.OnNextPageButton)
        EVT_WINDOW_DESTROY(self, self.OnExit)

        # Create shared application client        
        self.sharedAppClient = SharedAppClient(name)
        self.log = self.sharedAppClient.InitLogging()
        self.log.debug("PdfViewer.__init__: Start pdf viewer, venueUrl: %s, appUrl: %s"%(venueUrl, appUrl))

        # Get client profile
        clientProfile = ClientProfile(UserConfig.instance().GetProfile())
       
        # Join the application session.
        self.sharedAppClient.Join(appUrl, clientProfile)
        self.id = self.sharedAppClient.GetPublicId()
                
        # Register callbacks for external events
        self.sharedAppClient.RegisterEventCallback("openFile", self.OpenCallback)
        self.sharedAppClient.RegisterEventCallback("changePage", self.ChangePageCallback)

        # Create data store interface
        self.dataStoreClient = GetVenueDataStore(venueUrl, connectionId)

        self.file = None
        self.pageNr = 1
        
        # Get current state
        self.file = str(self.sharedAppClient.GetData("file"))
        self.pageNr = int(self.sharedAppClient.GetData("page"))
        if not self.pageNr:
            self.pageNr = 1

        if self.file:
            try:
                self.dataStoreClient.Download(self.file, "tmp")
                self.pdf.LoadFile("tmp")
                self.pdf.setCurrentPage( int(self.pageNr))
            except:
                self.log.exception("PdfViewer.__init__: Download failed %s"%(self.file))
Beispiel #10
0
def ping(host, port, count):
    try:
        # Create the text client
        profile = ClientProfile()
        textClient = TextClient(profile, (host, port))

        # Connect and send
        privId = str(GUID())
        textClient.Connect(channel, privId)
        #         pubId = profile.GetPublicId()
        #         for i in range(count):
        #             textClient.Input("%s -- %d" % (pubId, i))
        queue.put(0)
    except TextClientConnectException, e:
        print "EXCEPTION in text", sys.exc_type, sys.exc_value
        queue.put(2)
Beispiel #11
0
    def __init__(self, parent):
        '''
        Starts TextServiceSender

        **Arguments**
        *eventList* buffer where to insert sent events
        *lock* lock for eventList (also used by EventServiceController)
        *nrOfEvents* how many events of each type should get sent
        '''
        self.parent = parent
        self.privateId = str(GUID())
        self.eventList = parent.eventsOut
        self.receiveList = []
        self.lock = parent.sendLock
        self.nrOfEvent = parent.nrOfMessages
        self.profile = ClientProfile()
        self.profile.name = "client" + str(self.parent.index)
        self.parent.index = self.parent.index + 1
Beispiel #12
0
def main():
    venueServerPort = 8000
    if len(sys.argv) > 1:
        venueServerPort = sys.argv[1]
    venueServerUri = 'https://localhost:%s/Venues/default' % (venueServerPort)

    #
    # Create a local venueclient object for handling the
    # client/venue protocol.
    #

    clientObj = VenueClient.VenueClient()
    profile = ClientProfile('userProfile')
    clientObj.SetProfile(profile)
    clientObj.EnterVenue(venueServerUri)

    browser(clientObj, venueServerUri)

    print "Exiting"
    clientObj.ExitVenue()
    def __init__(self,
                 frame,
                 text,
                 text2="",
                 style=wx.ICON_ERROR | wx.YES_NO | wx.NO_DEFAULT,
                 logFile=VENUE_CLIENT_LOG,
                 extraBugCommentText=""):
        info = text + "\n\nDo you wish to send an automated error report?"
        errorDialog = wx.MessageDialog(frame, info, text2, style)

        if (errorDialog.ShowModal() == wx.ID_YES):
            # The user wants to send an error report
            bugReportCommentDialog = BugReportCommentDialog(frame)

            if (bugReportCommentDialog.ShowModal() == wx.ID_OK):
                # Submit the error report to Bugzilla
                comment = bugReportCommentDialog.GetComment()
                email = bugReportCommentDialog.GetEmail()
                try:
                    # load profile
                    userConfig = Config.UserConfig.instance()
                    profileFile = os.path.join(userConfig.GetConfigDir(),
                                               "profile")
                    profile = ClientProfile(profileFile)
                except:
                    profile = None

                if len(extraBugCommentText) > 0:
                    comment = comment + "\n\n----------------\n\n" + extraBugCommentText
                SubmitBug(comment, profile, email, logFile)
                bugFeedbackDialog = wx.MessageDialog(
                    frame,
                    "Your error report has been sent, thank you.",
                    "Error Reported",
                    style=wx.OK | wx.ICON_INFORMATION)
                bugFeedbackDialog.ShowModal()
                bugFeedbackDialog.Destroy()

            bugReportCommentDialog.Destroy()

        errorDialog.Destroy()
    def CreateEvents(self):
        dataDescription = DataDescription3("")
        profile = ClientProfile()
        service = ServiceDescription("service", "desc", "uri", "mime")
        stream = StreamDescription3("")
        conn = ConnectionDescription("")
        app = ApplicationDescription(1, 'app', 'desc', 'uri', 'mime')

        self.sendEvents = [
            Events.AddDataEvent(self.esc.GetChannelId(), dataDescription),
            Events.UpdateDataEvent(self.esc.GetChannelId(), dataDescription),
            Events.RemoveDataEvent(self.esc.GetChannelId(), dataDescription)
        ]

        self.distributeEvents = [
            Event(Event.ADD_DATA, self.esc.GetChannelId(), dataDescription),
            Event(Event.UPDATE_DATA, self.esc.GetChannelId(), dataDescription),
            Event(Event.REMOVE_DATA, self.esc.GetChannelId(), dataDescription),
            Event(Event.ENTER, self.esc.GetChannelId(), profile),
            Event(Event.MODIFY_USER, self.esc.GetChannelId(), profile),
            Event(Event.EXIT, self.esc.GetChannelId(), profile),
            Event(Event.ADD_SERVICE, self.esc.GetChannelId(), service),
            Event(Event.REMOVE_SERVICE, self.esc.GetChannelId(), service),
            Event(Event.ADD_APPLICATION, self.esc.GetChannelId(), app),
            Event(Event.REMOVE_APPLICATION, self.esc.GetChannelId(), app),
            Event(Event.ADD_CONNECTION, self.esc.GetChannelId(), conn),
            Event(Event.REMOVE_CONNECTION, self.esc.GetChannelId(), conn),
            Event(Event.ADD_STREAM, self.esc.GetChannelId(), stream),
            Event(Event.MODIFY_STREAM, self.esc.GetChannelId(), stream),
            Event(Event.REMOVE_STREAM, self.esc.GetChannelId(), stream)
        ]

        # Each client will receive all events.
        self.totalEvents = self.nrOfClients * len(
            self.distributeEvents) * self.nrOfEvent
        print 'Starting one event service and %s event clients' % (nrOfClients)
Beispiel #15
0
class FrameExtended(wx.Frame):
    def __init__(self, parent, id, title, appUrl, venueUrl, connectionId):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
                          wx.Size(800, 600))
        #wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(800, 600), wx.DEFAULT_FRAME_STYLE^(wx.RESIZE_BORDER | wx.MINIMIZE_BOX |wx.MAXIMIZE_BOX))
        #self.SetIcon(wx.Icon('ico/sharedpaint.ico', wx.BITMAP_TYPE_ICO))

        self.appUrl = appUrl
        self.venueUrl = venueUrl
        self.connectionId = connectionId

        print self.appUrl, self.venueUrl, self.connectionId

        # <AGtk code>
        reactor.interleave(wx.CallAfter)

        # Create shared application client
        self.sharedAppClient = SharedAppClient("SharedPaint")
        self.log = self.sharedAppClient.InitLogging()
        self.log.debug("GroupPaint.__init__: Started Group Paint")

        # Get client profile
        try:
            self.clientProfileFile = os.path.join(
                UserConfig.instance().GetConfigDir(), "profile")
            self.clientProfile = ClientProfile(self.clientProfileFile)

        except:
            self.log.info(
                "SharedQuestionTool.__init__: Could not load client profile, set clientProfile = None"
            )
            self.clientProfile = None

        # Join the application session
        self.sharedAppClient.Join(self.appUrl, self.clientProfile)
        self.publicId = self.sharedAppClient.GetPublicId()
        self.user = self.clientProfile.GetName()
        self.id = self.sharedAppClient.GetPublicId()

        # Register event callback
        self.sharedAppClient.RegisterEventCallback(events.CONSOLE_EVENT,
                                                   self.GetConsoleEventData)
        self.sharedAppClient.RegisterEventCallback(events.CLEAR_EVENT,
                                                   self.GetClearEvent)
        self.sharedAppClient.RegisterEventCallback(events.SET_BG_EVENT,
                                                   self.GetSetBGEvent)
        self.sharedAppClient.RegisterEventCallback(events.OPENFILE_EVENT,
                                                   self.OpenFileEvent)
        # </AGtk code>
        """
        Setting status bar
        """
        self.CreateStatusBar()

        workspace = wx.BoxSizer(wx.VERTICAL)
        imagePanel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        """
        Painter
        """
        self.painter = DoodleWindow(imagePanel, -1, self.clientProfile,
                                    self.sharedAppClient)

        imageBox = wx.BoxSizer(wx.VERTICAL)
        imageBox.Add(self.painter, 1, wx.EXPAND | wx.ALL, 1)
        imagePanel.SetSizer(imageBox)
        """
        Console settings
        """
        consolePanel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)

        self.console = wx.TextCtrl(consolePanel, -1, style=wx.TE_MULTILINE)
        self.console.SetEditable(0)

        consoleBox = wx.BoxSizer(wx.VERTICAL)
        consoleBox.Add(self.console, 1, wx.EXPAND | wx.ALL, 1)
        consolePanel.SetSizer(consoleBox)

        workspace.Add(imagePanel, 4, wx.EXPAND | wx.ALL, 1)
        workspace.Add(consolePanel, 1, wx.EXPAND | wx.ALL, 1)

        self.SetSizer(workspace)

        self.file_to_load = self.sharedAppClient.GetData('current_file')
        if self.file_to_load:
            self.LoadFile(self.file_to_load)

    ## makes the menu bar
    # @param self The object pointer
    def MakeMenu(self):

        menu = wx.MenuBar()
        options = wx.Menu()
        """
        Adding menu item
        """
        options.Append(101, "&Open", "Open background image")
        options.AppendSeparator()
        options.Append(102, "Clear background", "Clear background image")
        options.Append(103, "Clear drawing", "Clear drawing area")
        options.AppendSeparator()
        options.Append(104, "Help/About", "Further information")
        options.AppendSeparator()
        options.Append(106, "Download", "Download image from server")
        options.AppendSeparator()
        close = wx.MenuItem(options, 105, "&Close\tCtrl+C",
                            "Close application")
        """
        Adding an icon to the close menu option
        """
        #close.SetBitmap(wx.Image('./pixmaps/frame.gif', wx.BITMAP_TYPE_GIF).ConvertToBitmap())
        options.AppendItem(close)
        """
        Adding menu items
        """
        menu.Append(options, "Options")
        """
        Setting  menu bar
        """
        self.SetMenuBar(menu)

        self.Bind(wx.EVT_MENU, self.OnOpenFile, id=101)
        self.Bind(wx.EVT_MENU, self.OnClearBackground, id=102)
        self.Bind(wx.EVT_MENU, self.OnClearDrawing, id=103)
        self.Bind(wx.EVT_MENU, self.OnHelp, id=104)
        self.Bind(wx.EVT_MENU, self.OnClose, id=105)
        self.Bind(wx.EVT_MENU, self.OnDowloadFile, id=106)

    ## Shows a file list from server
    # @param self The object pointer
    def OnDowloadFile(self, event):
        browser = ServerFileBrowser(self, -1, "Select file", self.venueUrl,
                                    self.connectionId)
        browser.ShowModal()
        fname = browser.getSelectedFile()
        if fname != None:
            if self.LoadFile(fname):
                self.sharedAppClient.SendEvent(event.OPENFILE_EVENT, fname)
                self.sharedAppClient.SetData('current_file', fname)

    ## Open image event
    # @param self The object pointer
    def OpenFileEvent(self, event):
        id = event.GetSenderId()
        nameImage = event.data
        if cmp(self.id, id) != 0:
            self.LoadFile(nameImage)

    ## Open a image file after downloading
    # @param self The object pointer
    # @param pathfile path
    def LoadFile(self, nameImage):
        # Create a temp file
        t = string.split(nameImage, '.')
        ext = ''
        if len(t) > 1:
            ext = '.' + t[len(t) - 1]

        (fd, tname) = tempfile.mkstemp(suffix=ext)
        os.close(fd)
        try:
            dsc = GetVenueDataStore(self.venueUrl, self.connectionId)
            dsc.Download(nameImage, tname)
            self.painter.SetBackground(tname)
            return True
        except Exception, e:
            print "No se pudo localizar el VenueDataStore: " + e[0].__str__()
            return False
Beispiel #16
0
 def testSetGetName(self):
     c = ClientProfile()
     c.SetName("test name")
     assert "test name" == c.GetName()
Beispiel #17
0
 def testGetDistinguishedName(self):
     c = ClientProfile()
     dname = c.GetDistinguishedName()
    appUrl = "https://zuz-10:8000/102"
  
    def Callback(event):
        print '**** Received event (first)', event.GetData()

    def Callback2(event):
        print '**** Received event (second)', event.GetData()
    
    # Create shared application c  print "get data keys ", self.sharedAppClient.GetDataKeys()lient
    sharedAppClient = SharedAppClient("Test Client")
    sharedAppClient.InitLogging()

    # Get client profile
    clientProfileFile = os.path.join(UserConfig.instance().GetConfigDir(),
                                     "profile")
    clientProfile = ClientProfile(clientProfileFile)
    
    # Connect to shared application service. 
    sharedAppClient.Join(appUrl, clientProfile)
    
    # Register callback
    sharedAppClient.RegisterEventCallback("event1", Callback )
    sharedAppClient.RegisterEventCallback("event1", Callback2)
       
    print "\n--set data; dataKey1:data1, dataKey2:data2"
    sharedAppClient.SetData("key1", "data1")
    sharedAppClient.SetData("key2", "data2")
    print "\n--get data keys; "
    keys = sharedAppClient.GetDataKeys()
    for k in keys:
        print "   ", k
           type="int",
           dest="timeout",
           default=10,
           metavar="TIMEOUT",
           help="Set the timeout"))

app.Initialize('EnterVenue')

venueUrl = app.GetOption("venueUrl")
timeout = app.GetOption("timeout")

proxy = Client.SecureHandle(venueUrl).GetProxy()

log = app.GetLog()
# create client profile
profile = ClientProfile()
profile.SetName("nagios")


def Enter(venueUrl):
    # enter

    runningFlag.set()
    try:
        (state, privateId, streamDescList) = proxy.Enter(profile)
        enteredFlag.set()
    except:
        log.exception("Enter exception")
        runningFlag.clear()
        return
Beispiel #20
0
    def __init__(self, parent, id, title, appUrl):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
                          wx.Size(800, 600))
        #wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(800, 600), wx.DEFAULT_FRAME_STYLE^(wx.RESIZE_BORDER | wx.MINIMIZE_BOX |wx.MAXIMIZE_BOX))
        #self.SetIcon(wx.Icon('ico/sharedpaint.ico', wx.BITMAP_TYPE_ICO))

        self.appUrl = appUrl

        # <AGtk code>
        reactor.interleave(wx.CallAfter)

        # Create shared application client
        self.sharedAppClient = SharedAppClient("SharedPaint")
        self.log = self.sharedAppClient.InitLogging()
        self.log.debug("GroupPaint.__init__: Started Group Paint")

        # Get client profile
        try:
            self.clientProfileFile = os.path.join(
                UserConfig.instance().GetConfigDir(), "profile")
            self.clientProfile = ClientProfile(self.clientProfileFile)

        except:
            self.log.info(
                "SharedQuestionTool.__init__: Could not load client profile, set clientProfile = None"
            )
            self.clientProfile = None

        # Join the application session
        self.sharedAppClient.Join(self.appUrl, self.clientProfile)
        self.publicId = self.sharedAppClient.GetPublicId()
        self.user = self.clientProfile.GetName()
        self.id = self.sharedAppClient.GetPublicId()

        # Register event callback
        self.sharedAppClient.RegisterEventCallback(events.CONSOLE_EVENT,
                                                   self.GetConsoleEventData)
        self.sharedAppClient.RegisterEventCallback(events.CLEAR_EVENT,
                                                   self.GetClearEvent)
        #self.sharedAppClient.RegisterEventCallback(events.SET_BG_EVENT, self.GetSetBGEvent)
        # </AGtk code>
        """
        Setting status bar
        """
        self.CreateStatusBar()

        workspace = wx.BoxSizer(wx.VERTICAL)
        imagePanel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        """
        Painter
        """
        self.painter = DoodleWindow(imagePanel, -1, self.clientProfile,
                                    self.sharedAppClient)

        imageBox = wx.BoxSizer(wx.VERTICAL)
        imageBox.Add(self.painter, 1, wx.EXPAND | wx.ALL, 1)
        imagePanel.SetSizer(imageBox)
        """
        Console settings
        """
        consolePanel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)

        self.console = wx.TextCtrl(consolePanel, -1, style=wx.TE_MULTILINE)
        self.console.SetEditable(0)

        consoleBox = wx.BoxSizer(wx.VERTICAL)
        consoleBox.Add(self.console, 1, wx.EXPAND | wx.ALL, 1)
        consolePanel.SetSizer(consoleBox)

        workspace.Add(imagePanel, 4, wx.EXPAND | wx.ALL, 1)
        workspace.Add(consolePanel, 1, wx.EXPAND | wx.ALL, 1)

        self.SetSizer(workspace)
Beispiel #21
0
 def testSetGetEmail(self):
     c = ClientProfile()
     c.SetEmail("*****@*****.**")
     assert "*****@*****.**" == c.GetEmail()
Beispiel #22
0
    NUM_VENUE_CLIENTS = 3
    NUM_ROUNDTRIPS = 20

    #
    # process arguments
    venueUri = "https://localhost:8000/Venues/default"
    if len(sys.argv) > 1:
        venueUri = sys.argv[1]


    vcList = []

    print "Creating venue clients"
    for id in range(NUM_VENUE_CLIENTS):
        profile = ClientProfile('userProfile')
        profile.name = "User"+str(id)
        profile.publicId = profile.publicId + str(id)
        vcList.append( MyVenueClient( profile ) )


    for i in range(NUM_ROUNDTRIPS):
        print "Roundtrip: ", i
        print "Clients entering: "
        for vc in vcList:
            print "  ", vc.profile.name
            try:
                vc.EnterVenue( venueUri )
            except:
                print sys.exc_type
                print sys.exc_value
Beispiel #23
0
 def testSetGetHomeVenue(self):
     c = ClientProfile()
     c.SetHomeVenue("https://vv2.mcs.anl.gov:9000/Venues/default")
     assert "https://vv2.mcs.anl.gov:9000/Venues/default" == c.GetHomeVenue(
     )
Beispiel #24
0
 def testSetGetLocation(self):
     c = ClientProfile()
     c.SetLocation("somelocation")
     assert "somelocation" == c.GetLocation()
class Preferences:
    '''
    Class including accessors to user preferences.
    '''
    SHUTDOWN_MEDIA = "shutdownMedia"
    RECONNECT = "reconnect"
    MAX_RECONNECT = "maxReconnect"
    RECONNECT_TIMEOUT = "reconnectTimeout"
    STARTUP_MEDIA = "startupMedia"
    NODE_URL = "defaultNodeServiceUrl"
    NODE_BUILTIN = "nodeBuiltin"
    NODE_CONFIG = "defaultNodeConfig"
    NODE_CONFIG_TYPE = "defaultNodeConfigType"
    MULTICAST = "multicast"
    BEACON = "beacon"
    LOG_TO_CMD = "logToCmd"
    ENABLE_DISPLAY = "enableDisplay"
    ENABLE_VIDEO = "enableVideo"
    ENABLE_AUDIO = "enableAudio"
    DISPLAY_MODE = "displayMode"
    EXITS = "exits"
    MY_VENUES = "my venues"
    ALL_VENUES = "all venues"
    BRIDGE_REGISTRY = "bridgeRegistry"
    PROXY_ENABLED = "proxyEnabled"
    PROXY_HOST = "proxyHost"
    PROXY_PORT = "proxyPort"
    PROXY_USERNAME = "******"
    PROXY_PASSWORD = "******"
    PROXY_AUTH_ENABLED = "proxyAuthEnabled"
    PROXY_AUTH_KEY = "proxyAuthPasswordKey"
    MULTICAST_DETECT_HOST = "multicastDetectHost"
    MULTICAST_DETECT_PORT = "multicastDetectPort"
    BRIDGE_PING_UPDATE_DELAY = "bridgePingUpdateDelay"
    ORDER_BRIDGES_BY_PING = "orderBridgesByPing"
    VENUESERVER_URLS = "venueServerUrls"

    def __init__(self):
        '''
        Initiate preferences class. Simple client configuration
        parameters are saved in preferences dictionary. More
        complicated data structures are added as separate class
        objects and are saved to separate config file, for example
        client profile.
        '''

        self.preferences = {}

        # Default preferences
        self.default = {
            self.SHUTDOWN_MEDIA: 0,
            self.RECONNECT: 1,
            self.MAX_RECONNECT: 3,
            self.RECONNECT_TIMEOUT: 10,
            self.STARTUP_MEDIA: 1,
            self.NODE_BUILTIN: "1",
            self.NODE_URL: "",
            self.NODE_CONFIG_TYPE: NodeConfigDescription.SYSTEM,
            self.NODE_CONFIG: "default",
            self.MULTICAST: 1,
            self.BEACON: 1,
            self.LOG_TO_CMD: 0,
            self.ENABLE_DISPLAY: 1,
            self.ENABLE_VIDEO: 1,
            self.ENABLE_AUDIO: 1,
            self.DISPLAY_MODE: self.EXITS,
            self.BRIDGE_REGISTRY:
            "http://www.accessgrid.org/registry/peers.txt|http://www.ap-accessgrid.org/registry/peers.txt",
            self.PROXY_ENABLED: 0,
            self.PROXY_HOST: "",
            self.PROXY_PORT: "",
            self.PROXY_USERNAME: "",
            self.PROXY_PASSWORD: "",
            self.PROXY_AUTH_KEY: "stR1ng 1s SixTEN",
            self.PROXY_AUTH_ENABLED: 0,
            self.MULTICAST_DETECT_HOST: "233.4.200.18",
            self.MULTICAST_DETECT_PORT: 10002,
            self.BRIDGE_PING_UPDATE_DELAY: 600,
            self.ORDER_BRIDGES_BY_PING: 1,
            self.VENUESERVER_URLS: "https://vv3.mcs.anl.gov:8000/VenueServer"
        }

        # Set default log levels to Log.DEBUG.
        # Keys used for log preferences
        # are the same as listed in Log.py.
        # Save log levels as
        # Log.VenueClient=Log.DEBUG.
        categories = Log.GetCategories()
        for category in categories:
            self.default[category] = Log.DEBUG
        self.default[Log.RTPSensor] = Log.CRITICAL

        # Use the already implemented parts of
        # client profile. Save client profile
        # to separate profile file.
        self.profile = ClientProfile()

        # Use the bridge cache object. Save bridges
        # to separate file
        self.bridgeCache = BridgeCache()

        # Use already implemented parts of
        # node service. Default node service
        # config will get saved using the node
        # service.
        self.nodeConfigs = []
        self.config = UserConfig.instance(initIfNeeded=0)
        self.__bridges = {}  # Stores current bridges to display in UI
        self.LoadPreferences()

        self.venueClient = None

    def SetVenueClient(self, venueClient):
        self.venueClient = venueClient

    def GetPreference(self, preference):
        '''
        Accessor for client preferences. If the preference
        is not set, the method returns default value.
        
        ** Arguments **

        *preference* Preference you want to know value of

        ** Returns **

        *value* Value for preference
        '''
        r = None
        if self.preferences.has_key(preference):
            r = self.preferences[preference]

        elif self.default.has_key(preference):
            r = self.default[preference]
        else:
            return Exception, "Preferences.GetPreference: %s does not exist in preferences" % preference
        return r

    def SetPreference(self, preference, value):
        '''
        Set value for preference.
        
        ** Arguments **

        *preference* Preference to set

        *value* Value for preference
        '''
        self.preferences[preference] = value

    def StorePreferences(self):
        '''
        Save preferences to config file using INI file format.
        Client profile is saved separately.
        '''
        tempDict = {}

        # Add category to preference
        for key in self.preferences.keys():
            tempDict["Preferences." + key] = self.preferences[key]

        # Save preference
        try:
            log.debug("Preferences.StorePreferences: open file")
            SaveConfig(self.config.GetPreferences(), tempDict)
            os.chmod(self.config.GetPreferences(), 0600)
        except:
            log.exception("Preferences.StorePreferences: store file error")

        # Save client profile in separate file.
        try:
            profileFile = os.path.join(self.config.GetConfigDir(), "profile")
            self.profile.Save(profileFile)
        except:
            log.exception(
                "Preferences.StorePreferences: store profile file error")

        self.StoreBridges()

    def StoreBridges(self):

        # Save bridge information in separate file
        self.bridgeCache.StoreBridges(self.__bridges.values())

    def LoadPreferences(self):
        '''
        Read preferences from configuration file.
        '''
        try:
            log.debug("Preferences.LoadPreferences: open file")
            preferences = LoadConfig(self.config.GetPreferences())

            # Remove category from preference
            for p in preferences.keys():
                category = p.split(".")[0]
                pref = p.split(".")[1]

                if category == "Preferences":
                    self.preferences[pref] = preferences[p]

            # Add any default preferences that are missing
            for key in self.default:
                if not self.preferences.has_key(key):

                    # set the initial value of the proxy enabled preference based on whether
                    # the user has specified a proxy host previously
                    # note:  this only happens the first time a preferences file is loaded that
                    # is missing the PROXY_ENABLED preference
                    if key == self.PROXY_ENABLED:
                        if self.preferences.has_key(self.PROXY_HOST) and len(
                                self.preferences[self.PROXY_HOST]) > 0:
                            self.preferences[key] = 1
                            continue
                    self.preferences[key] = self.default[key]

        except:
            log.exception("Preferences.LoadPreferences: open file error")
            self.preferences = {}

        # Load client profile separately
        try:
            profileFile = os.path.join(self.config.GetConfigDir(), "profile")
            self.profile = ClientProfile(profileFile)

        except IOError:
            log.exception("Preferences.LoadPreferences: open file io error")

        # Load bridges separately
        for b in self.bridgeCache.GetBridges():
            self.__bridges[b.GetKey()] = b

    def ResetPreferences(self):
        '''
        Reset all preferences to default values. The preferences will
        also get stored in configuration file.
        '''
        for key in self.default.GetKeys():
            self.preferences[key] = self.default[key]

        self.StorePreferences()

    def GetDefaultNodeConfig(self):
        configs = self.GetNodeConfigs()
        defaultName = self.GetPreference(self.NODE_CONFIG)
        defaultType = self.GetPreference(self.NODE_CONFIG_TYPE)

        for c in configs:
            if c.name == defaultName and c.type == defaultType:
                return c

        return None

    def SetBridges(self, bridges):
        self.__bridges = bridges

    def GetBridges(self):
        return self.__bridges

    def GetNodeConfigs(self):
        '''
        Get all available node configuration from a node service.

        ** Returns **
        *configs* list of node configurations [string]
        '''
        if self.GetPreference(self.NODE_BUILTIN):
            nodeService = self.venueClient.builtInNodeService
        else:
            nodeServiceUrl = self.GetPreference(self.NODE_URL)
            nodeService = AGNodeServiceIW(nodeServiceUrl)

        configs = []
        try:
            if nodeService:
                configs = nodeService.GetConfigurations()
        except:
            log.exception('Failed to retrieve node configurations')

        return configs

    def SetProfile(self, profile):
        '''
        Set client profile describing your personal information.

        ** Arguments **
        
        * profile * ClientProfile with your information.
        '''
        # To avoid storing redundant information, save
        # client preferences in profile file.
        if type(profile) != ClientProfile:
            return Exception, "Invalid Type: SetProfile takes a ClientProfile as argument"
        self.profile = profile

    def GetProfile(self):
        '''
        Get client profile describing your personal information.

        **Returns**

        * clientProfile * ClientProfile with your information. 
        '''
        return self.profile

    def SetProxyPassword(self, password):
        '''
        Encrypts a password using the "secret" key
        '''
        if password:
            encryptedPassword = Crypto.encrypt(
                password,
                self.GetPreference(self.PROXY_AUTH_KEY)).encode("hex")
            self.SetPreference(Preferences.PROXY_PASSWORD, encryptedPassword)
        else:
            self.SetPreference(Preferences.PROXY_PASSWORD, "")

    def GetProxyPassword(self):
        '''
        Retrieves and decrypts the password
        
        ** Returns **
                
        The password in cleartext
        '''
        encryptedPassword = self.GetPreference(self.PROXY_PASSWORD)
        if encryptedPassword:
            password = Crypto.decrypt(encryptedPassword.decode("hex"),
                                      self.GetPreference(self.PROXY_AUTH_KEY))
            return password
        else:
            return ""
    def __init__(self):
        '''
        Initiate preferences class. Simple client configuration
        parameters are saved in preferences dictionary. More
        complicated data structures are added as separate class
        objects and are saved to separate config file, for example
        client profile.
        '''

        self.preferences = {}

        # Default preferences
        self.default = {
            self.SHUTDOWN_MEDIA: 0,
            self.RECONNECT: 1,
            self.MAX_RECONNECT: 3,
            self.RECONNECT_TIMEOUT: 10,
            self.STARTUP_MEDIA: 1,
            self.NODE_BUILTIN: "1",
            self.NODE_URL: "",
            self.NODE_CONFIG_TYPE: NodeConfigDescription.SYSTEM,
            self.NODE_CONFIG: "default",
            self.MULTICAST: 1,
            self.BEACON: 1,
            self.LOG_TO_CMD: 0,
            self.ENABLE_DISPLAY: 1,
            self.ENABLE_VIDEO: 1,
            self.ENABLE_AUDIO: 1,
            self.DISPLAY_MODE: self.EXITS,
            self.BRIDGE_REGISTRY:
            "http://www.accessgrid.org/registry/peers.txt|http://www.ap-accessgrid.org/registry/peers.txt",
            self.PROXY_ENABLED: 0,
            self.PROXY_HOST: "",
            self.PROXY_PORT: "",
            self.PROXY_USERNAME: "",
            self.PROXY_PASSWORD: "",
            self.PROXY_AUTH_KEY: "stR1ng 1s SixTEN",
            self.PROXY_AUTH_ENABLED: 0,
            self.MULTICAST_DETECT_HOST: "233.4.200.18",
            self.MULTICAST_DETECT_PORT: 10002,
            self.BRIDGE_PING_UPDATE_DELAY: 600,
            self.ORDER_BRIDGES_BY_PING: 1,
            self.VENUESERVER_URLS: "https://vv3.mcs.anl.gov:8000/VenueServer"
        }

        # Set default log levels to Log.DEBUG.
        # Keys used for log preferences
        # are the same as listed in Log.py.
        # Save log levels as
        # Log.VenueClient=Log.DEBUG.
        categories = Log.GetCategories()
        for category in categories:
            self.default[category] = Log.DEBUG
        self.default[Log.RTPSensor] = Log.CRITICAL

        # Use the already implemented parts of
        # client profile. Save client profile
        # to separate profile file.
        self.profile = ClientProfile()

        # Use the bridge cache object. Save bridges
        # to separate file
        self.bridgeCache = BridgeCache()

        # Use already implemented parts of
        # node service. Default node service
        # config will get saved using the node
        # service.
        self.nodeConfigs = []
        self.config = UserConfig.instance(initIfNeeded=0)
        self.__bridges = {}  # Stores current bridges to display in UI
        self.LoadPreferences()

        self.venueClient = None
Beispiel #27
0
 def testSetGetPublicId(self):
     c = ClientProfile()
     c.SetPublicId("myPublicId")
     assert "myPublicId" == c.GetPublicId()
Beispiel #28
0
		execString='vncviewer -shared -passwd %s %s'%(self.passwdFilename,self.vncContact)
            else:
		execString='chmod +x ./vncviewer; ./vncviewer -shared -passwd %s %s'%(self.passwdFilename,self.vncContact)
        elif IsOSX():
            vncviewer='/Applications/Chicken\ of\ the\ VNC.app/Contents/MacOS/Chicken\ of\ the\ VNC'
            execString='%s --PasswordFile %s %s' % (vncviewer,self.passwdFilename,self.vncContact)
        else:
            raise Exception("Unsupported platform")
        print "About the execute: %s"%(execString)
        log.info("Starting vnc client: %s", execString)
        os.system(execString);
        os.unlink(self.passwdFilename);

if __name__ == "__main__":
    app = CmdlineApplication.instance()
    app.Initialize("VenueVNCClient")

    log = app.GetLog()

    if len(sys.argv) < 2:
        print "Usage: %s <appObjectUrl>" % sys.argv[0]
        sys.exit(1)

    appUrl = sys.argv[1]

    clientProfileFile = os.path.join(UserConfig.instance().GetConfigDir(),
                                     "profile")
    clientProfile = ClientProfile(clientProfileFile)
    sb = vncSharedAppClient( appUrl, clientProfile )

Beispiel #29
0
 def testSetGetPhoneNumber(self):
     c = ClientProfile()
     c.SetPhoneNumber("867-5309")
     assert "867-5309" == c.GetPhoneNumber()
Beispiel #30
0
class FrameExtended(wx.Frame):
    def __init__(self, parent, id, title, appUrl):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
                          wx.Size(800, 600))
        #wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(800, 600), wx.DEFAULT_FRAME_STYLE^(wx.RESIZE_BORDER | wx.MINIMIZE_BOX |wx.MAXIMIZE_BOX))
        #self.SetIcon(wx.Icon('ico/sharedpaint.ico', wx.BITMAP_TYPE_ICO))

        self.appUrl = appUrl

        # <AGtk code>
        reactor.interleave(wx.CallAfter)

        # Create shared application client
        self.sharedAppClient = SharedAppClient("SharedPaint")
        self.log = self.sharedAppClient.InitLogging()
        self.log.debug("GroupPaint.__init__: Started Group Paint")

        # Get client profile
        try:
            self.clientProfileFile = os.path.join(
                UserConfig.instance().GetConfigDir(), "profile")
            self.clientProfile = ClientProfile(self.clientProfileFile)

        except:
            self.log.info(
                "SharedQuestionTool.__init__: Could not load client profile, set clientProfile = None"
            )
            self.clientProfile = None

        # Join the application session
        self.sharedAppClient.Join(self.appUrl, self.clientProfile)
        self.publicId = self.sharedAppClient.GetPublicId()
        self.user = self.clientProfile.GetName()
        self.id = self.sharedAppClient.GetPublicId()

        # Register event callback
        self.sharedAppClient.RegisterEventCallback(events.CONSOLE_EVENT,
                                                   self.GetConsoleEventData)
        self.sharedAppClient.RegisterEventCallback(events.CLEAR_EVENT,
                                                   self.GetClearEvent)
        #self.sharedAppClient.RegisterEventCallback(events.SET_BG_EVENT, self.GetSetBGEvent)
        # </AGtk code>
        """
        Setting status bar
        """
        self.CreateStatusBar()

        workspace = wx.BoxSizer(wx.VERTICAL)
        imagePanel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        """
        Painter
        """
        self.painter = DoodleWindow(imagePanel, -1, self.clientProfile,
                                    self.sharedAppClient)

        imageBox = wx.BoxSizer(wx.VERTICAL)
        imageBox.Add(self.painter, 1, wx.EXPAND | wx.ALL, 1)
        imagePanel.SetSizer(imageBox)
        """
        Console settings
        """
        consolePanel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)

        self.console = wx.TextCtrl(consolePanel, -1, style=wx.TE_MULTILINE)
        self.console.SetEditable(0)

        consoleBox = wx.BoxSizer(wx.VERTICAL)
        consoleBox.Add(self.console, 1, wx.EXPAND | wx.ALL, 1)
        consolePanel.SetSizer(consoleBox)

        workspace.Add(imagePanel, 4, wx.EXPAND | wx.ALL, 1)
        workspace.Add(consolePanel, 1, wx.EXPAND | wx.ALL, 1)

        self.SetSizer(workspace)

    ## Makes the menu bar
    # @param self The object pointer
    def MakeMenu(self):

        menu = wx.MenuBar()
        options = wx.Menu()
        """
        Adding menu item
        """
        options.Append(101, "&Open", "Open background image")
        options.AppendSeparator()
        options.Append(102, "Clear background", "Clear background image")
        options.Append(103, "Clear drawing", "Clear drawing area")
        options.AppendSeparator()
        options.Append(104, "Help/About", "Further information")
        options.AppendSeparator()
        close = wx.MenuItem(options, 105, "&Close\tCtrl+C",
                            "Close application")
        """
        Adding an icon to the close menu option
        """
        #close.SetBitmap(wx.Image('./pixmaps/frame.gif', wx.BITMAP_TYPE_GIF).ConvertToBitmap())
        options.AppendItem(close)
        """
        Adding menu items
        """
        menu.Append(options, "Options")
        """
        Setting  menu bar
        """
        self.SetMenuBar(menu)

        self.Bind(wx.EVT_MENU, self.OnOpenFile, id=101)
        self.Bind(wx.EVT_MENU, self.OnClearBackground, id=102)
        self.Bind(wx.EVT_MENU, self.OnClearDrawing, id=103)
        self.Bind(wx.EVT_MENU, self.OnHelp, id=104)
        self.Bind(wx.EVT_MENU, self.OnClose, id=105)

    ## Initialize the console object
    # @param self The object pointer
    def LoadConsole(self):
        self.PrintStartMessage()

    ## Open an image file
    # @param self The object pointer
    # @event event Menu event
    def OnOpenFile(self, event):
        dlg = wx.FileDialog(self, "Choose a image file", os.getcwd(), "",
                            "*.jpg", wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            mypath = os.path.basename(path)
            self.SetStatusText("Image file: %s" % mypath)
            self.painter.SetBackground(path)
            self.ConsoleMessage("File " + mypath + " loaded on background")

        dlg.Destroy()

    ## Close the application
    # @param self The object pointer
    # @event event Menu event
    def OnClose(self, event):
        dlg = wx.MessageDialog(self,
                               "Are you sure you want to close SharedPaint?",
                               "Confirm close", wx.YES_NO | wx.ICON_QUESTION)
        if dlg.ShowModal() == wx.ID_YES:
            dlg.Destroy()
            self.Close()
        else:
            dlg.Destroy()

    ## Clear the background image
    # @param self The object pointer
    # @event event Menu event
    def OnClearBackground(self, event):
        self.painter.SetBackground(None)
        # <AGtk event>
        self.ConsoleMessage("Background image unloaded")

    # </AGtk event>

    ## Clear the user drawing
    # @param self The object pointer
    # @event event Menu event
    def OnClearDrawing(self, event):
        self.sharedAppClient.SendEvent(events.CLEAR_EVENT, "")

    ## Display help frame
    # @param self The object pointer
    # @event event Menu event
    def OnHelp(self, event):
        helpFrame = HTMLFrame(self, -1, 'SharedPaint HELP')
        helpFrame.Centre()
        helpFrame.Show()

    ## Send a console message
    # @param self The object pointer
    # @param message The message
    def ConsoleMessage(self, _message):
        message = " " + self.user + " >> " + _message
        self.sharedAppClient.SendEvent(events.CONSOLE_EVENT, message)

    ## Print welcome message
    # @param self The object pointer
    def PrintStartMessage(self):
        startMessage = "*** AGTk - SharedPaint 1.2, Department of Systems and Computing Engineering, Universidad de los Andes ***" + "\n" + "See Help/About for further information" + "\n"
        self.console.WriteText(startMessage)

    ## Capture the console event
    # @param self The object pointer
    # @param event Event data
    def GetConsoleEventData(self, event):
        message = event.data
        dt = datetime.datetime.now()
        timestamp = "[" + dt.isoformat() + "]: "
        line = timestamp + message
        self.console.WriteText("\n" + line)

    ## Capture the set background event
    # @param self The object pointer
    # @param event Event data
    def GetSetBGEvent(self, event):
        pass

    ## Capture the clear drawing event
    # @param self The object pointer
    # @param event Event data
    def GetClearEvent(self, event):
        self.painter.SetLinesData([])
        self.ConsoleMessage("Drawing area cleared")
Beispiel #31
0
    appUrl = "https://zuz-10:8000/102"

    def Callback(event):
        print '**** Received event (first)', event.GetData()

    def Callback2(event):
        print '**** Received event (second)', event.GetData()

    # Create shared application c  print "get data keys ", self.sharedAppClient.GetDataKeys()lient
    sharedAppClient = SharedAppClient("Test Client")
    sharedAppClient.InitLogging()

    # Get client profile
    clientProfileFile = os.path.join(UserConfig.instance().GetConfigDir(),
                                     "profile")
    clientProfile = ClientProfile(clientProfileFile)

    # Connect to shared application service.
    sharedAppClient.Join(appUrl, clientProfile)

    # Register callback
    sharedAppClient.RegisterEventCallback("event1", Callback)
    sharedAppClient.RegisterEventCallback("event1", Callback2)

    print "\n--set data; dataKey1:data1, dataKey2:data2"
    sharedAppClient.SetData("key1", "data1")
    sharedAppClient.SetData("key2", "data2")
    print "\n--get data keys; "
    keys = sharedAppClient.GetDataKeys()
    for k in keys:
        print "   ", k
Beispiel #32
0
    from AccessGrid.Types import *

    NUM_VENUE_CLIENTS = 3
    NUM_ROUNDTRIPS = 20

    #
    # process arguments
    venueUri = "https://localhost:8000/Venues/default"
    if len(sys.argv) > 1:
        venueUri = sys.argv[1]

    vcList = []

    print "Creating venue clients"
    for id in range(NUM_VENUE_CLIENTS):
        profile = ClientProfile("userProfile")
        profile.name = "User" + str(id)
        profile.publicId = profile.publicId + str(id)
        vcList.append(MyVenueClient(profile))

    for i in range(NUM_ROUNDTRIPS):
        print "Roundtrip: ", i
        print "Clients entering: "
        for vc in vcList:
            print "  ", vc.profile.name
            try:
                vc.EnterVenue(venueUri)
            except:
                print sys.exc_type
                print sys.exc_value
                print sys.exc_info()
#-----------------------------------------------------------------------------
# Name:        ClientProfileTest.py
# Purpose:     Tests the Client Profile Class.
#
# Author:      Ivan R. Judson
#
# Created:     2003/28/01
# RCS-ID:      $Id: ClientProfileTest.py,v 1.1 2003-01-28 17:21:12 judson Exp $
# Copyright:   (c) 2002
# Licence:     See COPYING.TXT
#-----------------------------------------------------------------------------

from AccessGrid.ClientProfile import ClientProfile

empty = ClientProfile()
empty.Save("empty-test-out")

user = ClientProfile("userProfileExample")
user.Save("user-test-out")

node = ClientProfile("nodeProfileExample")
node.Save("node-test-out")