def __init__(self):

        # Init the toolkit with the standard environment.
        self.app = WXGUIApplication()
        
        # Try to initialize
        args = self.app.Initialize("VenueClient", sys.argv[:1])

        # Handle command line options
        self.__buildOptions()
              
        if not self.port:
            self.port = 8000

        if not self.url:
            self.url = 'https://localhost:8000/Venues/default'

        # Create venue client components
        self.vc = VenueClient(pnode=self.pnode, port=self.port)
        self.vcc = VenueClientController()
        self.vcc.gui = Gui()
        self.vcc.SetVenueClient(self.vc)
        self.observer = Observer()
        self.vc.AddObserver(self.observer)
                
        # Start tests
        self.__StartTests()
        
        # Exit
        self.vc.Shutdown()
        sys.exit(0)
Esempio n. 2
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()
Esempio n. 3
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()
Esempio n. 4
0
    def EnterVenue(self, URL):
        VenueClient.EnterVenue(self, URL)
        venueState = self.venueState

        print 'venue name: ', venueState.name
        print 'venue description: ', venueState.description

        users = venueState.clients.values()

        print '\n-------------USERS/NODES'
        for user in users:
            if (user.profileType == 'user'):
                print 'user: '******'node: ', user.name

        print '\n-------------DATA'
        data = venueState.data.values()
        for d in data:
            print 'data: ', d.name


#         print '\n-------------SERVICES'
#         services = venueState.services.values()
#         for service in services:
#             print 'service: ', service.name

        print '\n------------- EXITS'
        exits = venueState.connections.values()
        for exit in exits:
            print 'exit: ', exit.name

        pass
Esempio n. 5
0
 def ExitVenue(self ):
     """
     Note: Overloaded from VenueClient
     This method calls the venue client method and then
     performs its own operations when the client exits a venue.
     """
     VenueClient.ExitVenue( self )
 def __init__(self, profile, app):
     VenueClient.__init__(self, profile=profile, app=app,pnode=0)
Esempio n. 7
0
 def __init__(self, profile, app):
     VenueClient.__init__(self, profile=profile, app=app, pnode=0)
Esempio n. 8
0
    port = app.GetOption("port")
    nodeConfig = app.GetOption("configfilename")

    try:
        import wx
        wxversion_str = str(wx.VERSION_STRING)
        log.info("wx version is: " + wxversion_str)
    except:
        log.exception("Unable to log wx version.")

    try:

        # Create venue client components
        vc = VenueClient(pnode=pnode,
                         port=port,
                         app=app,
                         progressCB=progressDialog.UpdateGauge,
                         nodeConfigName=nodeConfig)
        vcc = VenueClientController()
        vcc.SetVenueClient(vc)

        #
        # If profile is the default profile, do first-time user initialization
        #
        profile = app.preferences.GetProfile()
        isFirstRun = profile.IsDefault()

        if isFirstRun:  # not your profile
            progressDialog.UpdateGauge('Initializing User Profile',
                                       increment=20)
            log.debug(
Esempio n. 9
0
 def ExitVenue(self):
     VenueClient.ExitVenue(self)
     os._exit(1)
Esempio n. 10
0
venueServer = VenueServerIW(serverUrl)
time_to_wait = 10
secs_past = 0
while secs_past < time_to_wait:
    try:
        venueList = venueServer.GetVenues()
        #print 'got venue list:', venueList
        break
    except Exception, e:
        print 'exception', e
    time.sleep(1)
    secs_past += 1

app = CmdlineApplication()
app.Initialize('qwe')
vc = VenueClient(app=app)
vcc = VenueClientController()
vcc.SetVenueClient(vc)


class TestCase(unittest.TestCase):
    def __init__(self, *args):

        unittest.TestCase.__init__(self, *args)

    def test1_Enter(self):
        vc.EnterVenue(venueUrl)
        print '* venue state'
        print 'clients:', vc.venueState.clients
        print 'data:', vc.venueState.data
        print 'services:', vc.venueState.services
class SystemTest:
    def __init__(self):

        # Init the toolkit with the standard environment.
        self.app = WXGUIApplication()
        
        # Try to initialize
        args = self.app.Initialize("VenueClient", sys.argv[:1])

        # Handle command line options
        self.__buildOptions()
              
        if not self.port:
            self.port = 8000

        if not self.url:
            self.url = 'https://localhost:8000/Venues/default'

        # Create venue client components
        self.vc = VenueClient(pnode=self.pnode, port=self.port)
        self.vcc = VenueClientController()
        self.vcc.gui = Gui()
        self.vcc.SetVenueClient(self.vc)
        self.observer = Observer()
        self.vc.AddObserver(self.observer)
                
        # Start tests
        self.__StartTests()
        
        # Exit
        self.vc.Shutdown()
        sys.exit(0)
        
    def __StartTests(self):
        # -------------------------------------
        # EnterVenue
        # -------------------------------------
        
        self.__testMethod(self.vc.EnterVenue, "EnterVenue", args = [self.url])
                
        # -------------------------------------
        # Services
        # -------------------------------------
        
        # AddService
        service = ServiceDescription("test", "test", "test", "test")
        service.SetId(5)
        self.__testMethod(self.vc.AddService, "AddService", args = [service])

        s = self.observer.lastService
        
        if not s.id == service.id:
            print 'Add Service FAILED; service does not exist'
        
        # UpdateService
        service.SetName("Updated Service")
        self.__testMethod(self.vc.UpdateService, "UpdateService", args = [service])
        
        # RemoveService
        self.__testMethod(self.vc.RemoveService, "RemoveService", args = [service])

        # -------------------------------------
        # Data
        # -------------------------------------

        # AddData
        file1 = os.path.join(os.getcwd(), 'unittest_all.py')
        file2 = os.path.join(os.getcwd(), 'unittest_ClientProfile.py')
        self.__testMethod(self.vcc.UploadVenueFiles, "UploadVenueFiles", args = [[file1,file2]])

        time.sleep(20)
        d = self.observer.lastData
        
        d.SetName("Updated Name")
        # ModifyData
        self.__testMethod(self.vc.ModifyData, "ModifyData", args = [d])

        # RemoveData

        
        # -------------------------------------
        # Applications
        # -------------------------------------
        
        # CreateApplication
        name = 'Test App'
        self.__testMethod(self.vc.CreateApplication, "CreateApplication", args = ['Test App', "my_desc", 'my_mime'])
        
        app = self.observer.lastApplication
        
        if not app.name == name:
            print 'Create Application Failed; app does not exist'
            
        # UpdateApplication
        app.SetName("Updated Application")
        self.__testMethod(self.vc.UpdateApplication, "UpdateApplication", args = [app])
        
        # DestroyApplication
        self.__testMethod(self.vc.DestroyApplication, "DestroyApplication", args = [app.id])

        # --------------------------------------
        # ExitVenue
        # --------------------------------------
        self.__testMethod(self.vc.ExitVenue, 'ExitVenue')

                  
    def __testMethod(self, method, text, args = None):

        print '******************************************'
        
        try:
            if args:
                return apply(method, args)
            else:
                return apply(method)
            print '%s SUCCEEDED'%text
        except:
            print '%s FAILED'%text
        
        print '******************************************'
        
                
    def __buildOptions(self):
        # build options for this application
        
        portOption = Option("-p", "--port", type="int", dest="port",
                                        default=0, metavar="PORT",
                                        help="Set the port the venueclient control interface\
                                        should listen on.")
        self.app.AddCmdLineOption(portOption)
        pnodeOption = Option("--personalNode", action="store_true", dest="pnode",
                             default=0,
                             help="Run NodeService and ServiceManager with the client.")
        self.app.AddCmdLineOption(pnodeOption)
        urlOption = Option("--url", type="string", dest="url",
                           default="", metavar="URL",
                           help="URL of venue to enter on startup.")
        self.app.AddCmdLineOption(urlOption)
                        
        self.log = self.app.GetLog()
        self.pnode = self.app.GetOption("pnode")
        self.url = self.app.GetOption("url")
        self.port = self.app.GetOption("port")