def testSaveLoad(self): c = ClientProfile() filename = os.path.join(SystemConfig.instance().GetTempDir(), ".testProfile") c.Save(filename) d = ClientProfile() d.Load(filename) assert d.CheckProfile()
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()
def test_150_SetIdentity(self): global nodeService profile = ClientProfile(UserConfig.instance().GetProfile()) nodeService.SetIdentity(profile)
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)
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)
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))
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)
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 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 __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
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)
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
def testSetGetEmail(self): c = ClientProfile() c.SetEmail("*****@*****.**") assert "*****@*****.**" == c.GetEmail()
def testSetGetName(self): c = ClientProfile() c.SetName("test name") assert "test name" == c.GetName()
def testGetDistinguishedName(self): c = ClientProfile() dname = c.GetDistinguishedName()
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
def testSetGetLocation(self): c = ClientProfile() c.SetLocation("somelocation") assert "somelocation" == c.GetLocation()
def testCheckProfile(self): c = ClientProfile() assert c.CheckProfile()
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( )
def testSetGetPublicId(self): c = ClientProfile() c.SetPublicId("myPublicId") assert "myPublicId" == c.GetPublicId()
def testSetGetPhoneNumber(self): c = ClientProfile() c.SetPhoneNumber("867-5309") assert "867-5309" == c.GetPhoneNumber()
def testIsDefault(self): c = ClientProfile() assert c.IsDefault()
def testSetGetProfileType(self): c = ClientProfile() c.SetProfileType("user") assert "user" == c.GetProfileType()
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 )
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 __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)
#----------------------------------------------------------------------------- # 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")