Esempio n. 1
0
def main():
    app = CmdlineApplication()

    portOption = Option("-p",
                        "--port",
                        type="int",
                        dest="port",
                        default=defaultPort,
                        metavar="PORT",
                        help="Set the port the RegistryPeer will use")
    app.AddCmdLineOption(portOption)

    urlOption = Option(
        "-u",
        "--peerListUrl",
        type="string",
        dest="peerListUrl",
        default=defaultPeerListUrl,
        metavar="URL",
        help=
        "The url to bootstrap the system. For the current design, this is a complete list of peers."
    )
    app.AddCmdLineOption(urlOption)

    try:
        args = app.Initialize("RegistryPeer")
    except Exception, e:
        print "Toolkit Initialization failed, exiting."
        print " Initialization Error: ", e
        sys.exit(-1)
def main():
    """
    The main routine.
    """
    # Instantiate the app
    app = CmdlineApplication()

    # Handle command-line arguments
    urlOption = Option("-u",
                       "--url",
                       dest="url",
                       default=0,
                       help="URL for the venue server to manage.")
    app.AddCmdLineOption(urlOption)

    # Initialize the application
    try:
        app.Initialize("VenueMgmt")
    except Exception, e:
        print "Exception: ", e
        sys.exit(0)
app = CmdlineApplication()

urlOption = Option("-u",
                   "--url",
                   dest="url",
                   default=None,
                   help="Specify a venue url on the command line.")
app.AddCmdLineOption(urlOption)
fileOption = Option("-f",
                    "--file",
                    dest="file",
                    default=None,
                    help="Specify a file that contains a venue url.")
app.AddCmdLineOption(fileOption)

args = app.Initialize()

venueUrl = app.GetOption("url")
fileName = app.GetOption("file")

print "URL: ", venueUrl
print "FILE: ", fileName
"""

    There are four valid command line possibilities:

    GoToVenue3.py --url url 
    GoToVenue3.py --url url --file fileName (use url)
    GoToVenue3.py --file fileName
    GoToVenue3.py Mime-Encoded.vv3d file (from web link)
 
    urlOption = Option("-u", "--url", dest="url",
                       default="https://localhost/VenueServer",
                       help="URL to the venue server to test.")
    app.AddCmdLineOption(urlOption)

    nvcOption = Option("-n", "--num-clients", dest="nc", type="int",
                       default=1, help="number of clients to use.")
    app.AddCmdLineOption(nvcOption)

    rtOption = Option("-t", "--traverse", dest="rt", type="int",
              default=10, help="number of venues each client will traverse.")
    app.AddCmdLineOption(rtOption)
    
    try:
       app.Initialize("ClientSwarm")
    except:
       print "Application initialize failed, exiting."
       sys.exit(-1)
       
    print "Getting default venue"
    venueUri = app.GetOption('url')

    vcList = list()

    print "Spawning venue clients"
    for id in range(app.GetOption("nc")):
       client = threading.Thread(target=RunClient, name="Venue Client %s" % id,
                                 kwargs = {'id':id, 'url': venueUri,
                                           'app' : app,
                                           'verbose' : verbose })
Esempio n. 5
0
#!/usr/bin/python

import os
import sys

from AccessGrid.VenueClient import GetVenueClientUrls
from AccessGrid.VenueClient import VenueClientIW
from AccessGrid.Platform import isWindows
from AccessGrid.Platform.Config import UserConfig
from AccessGrid.Toolkit import CmdlineApplication



# Initialize
app = CmdlineApplication()
app.Initialize()


if len(sys.argv) > 1:
    # Use the provided venue client url
    venueClientUrlList = [ sys.argv[1] ]
else:
    # Search for a venue client url
    venueClientUrlList = GetVenueClientUrls()

foundClient = 0
for venueClientUrl in venueClientUrlList:
    try:
        venueClient = VenueClientIW(venueClientUrl)
        venueClient._IsValid()
   def GetWidth(self):
      return self.proxy.GetWidth()

   def GetHeight(self):
      return self.proxy.GetHeight()

   def GetDepth(self):
      return self.proxy.GetDepth()
   
if __name__ == '__main__':
   from AccessGrid.Toolkit import CmdlineApplication
   import pprint
   
   # Do env init
   app = CmdlineApplication()
   app.Initialize("DisplayServiceTest")
   
   # Create a local hosting environment
   hn = SystemConfig.instance().GetHostname()
   hn = 'localhost'
   server = Server((hn, int(sys.argv[1])))

   # Create the display service
   dispService = DisplayService()

   # Then it's interface
   dispServiceI = DisplayServiceI(dispService)

   # Then register the display service with the hosting environment
   service = server.RegisterObject(dispServiceI, path = "/DisplayService")
#!/usr/bin/python
#
#

import csv

from AccessGrid.Toolkit import CmdlineApplication
from AccessGrid.ClientProfile import ClientProfileCache

app = CmdlineApplication()
app.Initialize("ListKnownProfiles")

cache = ClientProfileCache()

profiles = cache.loadAllProfiles()

def makeRow(p):
    d = dict()
    d['name'] = p.name
    d['email'] = p.email
    d['phone'] = p.phoneNumber
    d['location'] = p.location
    d['home venue'] = p.homeVenue
    return d

pKeys = ('name', 'email', 'phone', 'location', 'home venue')
outfile = csv.DictWriter(file("KnownUsers.csv", "w"), pKeys, lineterminator="\n")
for row in map(lambda p: makeRow(p), profiles):
    outfile.writerow(row)

#!/usr/bin/python
#
import sys
from optparse import Option

from AccessGrid.Toolkit import CmdlineApplication
from AccessGrid.VenueServer import VenueServerIW

app = CmdlineApplication()

urlOption = Option("-u",
                   "--url",
                   dest="url",
                   default=None,
                   help="URL to the server you want to shut down.")

app.AddCmdLineOption(urlOption)

try:
    args = app.Initialize("StopServer")
except Exception, e:
    print "Exception initializing toolkit:", e
    sys.exit(-1)

url = app.GetOption("url")
server = VenueServerIW(url)
server.Shutdown(0)
Esempio n. 9
0
                        help="Set the name by which the server will be identified in the venue.") )
    app.AddCmdLineOption( Option("--vncserverexe", type="string", dest="vncserverexe",
                        default=None, metavar="VNC_SERVER_EXE",
                        help="Set the VNC server executable to use") )

    app.AddCmdLineOption( Option("--display", type="string", dest="display",
                        default=":9", metavar="DISPLAY",
                        help="Set the display the VNC server should run on. (linux only)") )
    app.AddCmdLineOption( Option("-g", "--geometry", type="string", dest="geometry",
                        default="1024x768", metavar="GEOMETRY",
                        help="Set the geometry of the VNC server. (linux only)") )
    app.AddCmdLineOption( Option("--depth", type="int", dest="depth",
                        default=24, metavar="DEPTH",
                        help="Set the bit depth to use for the server. (linux only)") )

    app.Initialize("VenueVNCServer")
    log = app.GetLog()

    # Log options in debug mode
    if app.GetOption('debug'):
        log.info("Options:")
        for opt in ['venueUrl','name','vncserverexe','display','geometry','depth']:
            log.info('  %s = %s' % (opt,str(app.GetOption(opt))))
    
    # Verify venue url option
    if not app.GetOption('venueUrl'):
        msg = "VenueURL must be specified; exiting." 
        print msg
        log.info(msg)
        sys.exit(1)
    
Esempio n. 10
0
def main():
    """
    The main routine.
    """
    # Instantiate the app
    app = CmdlineApplication()

    caOption = Option(
        "-C",
        "--ca",
        action="store_true",
        dest="is_ca_mode",
        default=0,
        help="Use CA mode for this invocation of the certificate manager.")
    idOption = Option(
        "-I",
        "--id",
        action="store_false",
        dest="is_ca_mode",
        default=0,
        help="Use ID mode for this invocation of the certificate manager.")

    forceOption = Option("-f",
                         "--force",
                         action="store_true",
                         dest="force_overwrite",
                         default=0,
                         help="Overwrite existing files.")
    app.AddCmdLineOption(caOption)
    app.AddCmdLineOption(idOption)
    app.AddCmdLineOption(forceOption)

    try:
        args = app.Initialize("CertificateManager")
    except Exception:
        sys.exit(0)

    cmd = CertMgrCmdProcessor(app.GetCertificateManager(), app.GetLog())

    #
    # If no args were passed, start up the command-driver
    # cert mgr.
    #

    if app.GetOption("is_ca_mode"):
        cmd.setCAMode()

    if len(args) == 0:

        cmd.cmdloop()

    else:

        #
        # Otherwise, process a single command from teh command line.
        #

        cmd.setInteractive(0)
        cmd.setForceOverwrite(app.GetOption("force_overwrite"))

        mycmd = args[0] + " " + " ".join(map(lambda a: '"' + a + '"',
                                             args[1:]))
        print mycmd
        cmd.onecmd(mycmd)
Esempio n. 11
0
print 'serverUrl = ', serverUrl
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