Application -- Venue interaction
Eric Olson
eolson at mcs.anl.gov
Tue Sep 16 12:07:09 CDT 2003
Here is an update on the example to launch an application from the venue
and provide it with the current venue url.
The method to register an app was changed slightly (and made simpler) in
preparation for the 2.1.2 release.
Similar instructions as before:
1) Run "python RegisterSampleApplication.py"
2) Start VenueClient (in debug mode) and enter a venue.
3) Select the menu item: Venue, Applications, Start Sample Application.
You should see the venue url printed out in venueclient's debug window,
which means the sample application has been run.
Eric
On Fri, 12 Sep 2003, Eric Olson wrote:
>
> Here is a quick sample on how to use the venueUrl option that Ivan
> recently added. All this example does is register the app and then let
> your app be launched from the venueclient with the venueUrl provided as an
> argument. The SampleApp just prints the url and exits. I sent this to
> Terry, but others may want to comment on it or try it -- if so, just
> follow the instructions below.
> Eric
>
> ---------- Forwarded message ----------
> Date: Fri, 12 Sep 2003 14:42:45 -0500 (CDT)
> From: Eric Olson <eolson at mcs.anl.gov>
> To: Terrence Disz <disz at mcs.anl.gov>
> Subject: sample app
>
> Hi Terry,
>
> This only works in cvs right now and of course the methods for doing these
> things may change with future releases. The two files attached should be
> in the same directory.
>
> 1) Run RegisterSampleApp.py to register SampleApp.py.
>
> In windows (in linux use python2):
> python RegisterSampleApp.py
>
> 2) Restart the venueclient (in debug mode --debug so you can see the print
> statement later) and join a venue. You should see "Start Sample App" in
> venue applications. It will put a "Sample App" entry under Applications
> in the current venue, and will also run it.
>
> 3) Open or double-click the new "Sample App". The SampleApp.py will run
> and print out the current venue url (in windows, you will probably only
> see it if you run the venueclient in debug mode).
>
> You no longer need the two files because SampleApp.py has been copied to
> your .AccessGrid/SharedApplications directory and it runs from there.
>
> Let me know if you have any problems.
>
> Eric
>
>
-------------- next part --------------
#!/usr/bin/python2
# Normal import stuff
import os
import sys
import getopt
import logging
from threading import Thread
import Queue
import shutil
from wxPython.wx import *
# Imports we need from the Access Grid Module
from AccessGrid.hosting.pyGlobus import Client
from AccessGrid.EventClient import EventClient
from AccessGrid.Events import ConnectEvent, Event
from AccessGrid import Platform
from AccessGrid import DataStore
def registerApp(fileName):
import AccessGrid.Toolkit as Toolkit
app = Toolkit.CmdlineApplication()
appdb = app.GetAppDatabase()
fn = os.path.basename(fileName)
if sys.platform == Platform.WIN:
exeCmd = sys.executable + " \"" + fn + "\" %(venueUrl)s"
else:
exeCmd = sys.executable + " " + fn + " %(venueUrl)s"
# Call the registration method on the applications database
appdb.RegisterApplication("Sample Application",
"application/x-ag-sample-application",
"sampleapplication",
{"Open" : exeCmd },
[fn], os.getcwd())
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Utility functions
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# This gets logging started given the log name passed in
# For more information about the logging module, check out:
# http://www.red-dove.com/python_logging.html
#
def InitLogging(appName, debug=0):
"""
This method sets up logging so you can see what's happening.
If you want to see more logging information use the appName 'AG',
then you'll see logging information from the Access Grid Module.
"""
logFormat = "%(name)-17s %(asctime)s %(levelname)-5s %(message)s"
# Set up a venue client log, too, since it's used by the event client
log = logging.getLogger("AG.VenueClient")
log.setLevel(logging.DEBUG)
hdlr = logging.StreamHandler()
hdlr.setFormatter(logging.Formatter(logFormat))
log.addHandler(hdlr)
log = logging.getLogger(appName)
log.setLevel(logging.DEBUG)
# Log to file
logFile = appName + ".log"
fileHandler = logging.FileHandler(logFile)
fileHandler.setFormatter(logging.Formatter(logFormat))
log.addHandler(fileHandler)
# If debugging, log to command window too
if debug:
hdlr = logging.StreamHandler()
hdlr.setFormatter(logging.Formatter(logFormat))
log.addHandler(hdlr)
return log
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# MAIN block
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if __name__ == "__main__":
InitLogging("RegisterSampleApp")
registerApp("SampleApp.py")
-------------- next part --------------
import sys
print sys.argv
if len(sys.argv) > 1:
print "venue:", sys.argv[1]
More information about the ag-dev
mailing list