Give a name to the run operation, for this example we chose GridClient
Select GridClient as the project
Select GridClient/manage.py file as the Main Module
Select the Arguments tab
In Program arguments type runserver
By default Django will have the server on localhost:8000
To change the port number, in Program Arguments give runserver <port_number>
To change the host to an ip address, in Program Arguments give runserver <server_ip>:<port_number>
Select Apply, then select Run
The console will show the following
Validating models...
0 errors found
Django version 1.2.5, using settings 'GridClient.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Add imports, don't worry if eclipse complains about the imports
from java.util import Properties
from java.io import FileInputStream
from gov.nih.nci.cagrid.common import Utils
from gov.nih.nci.cagrid.syncgts.bean import SyncDescription
from gov.nih.nci.cagrid.syncgts.core import SyncGTS
import time
import thread
#load client.properties and return as properties object
def readProperties():
try:
tempprop=Properties()
tempprop.load(FileInputStream(CLIENT_PROPERTIES))
return tempprop
except Exception, e:
print "Exception while accessing %s %s" % (CLIENT_PROPERTIES,e)
Implement the syncTrust method
#sync with the trust fabric, every 15 minutes
def syncTrust():
while(1):
print "Synchronizing Trust Fabric"try:
description = Utils.deserializeDocument(props.getProperty(SYNC_DESCRIPTION), SyncDescription)
SyncGTS.getInstance().syncOnce(description)
print "Synchronizing Complete"
except Exception,e:
print "SyncGridTrust %s" % e
print "Failed to Synchronize"
time.sleep(15*60)
load the client.properties file and start a thread to sync with the trust fabric
#load client.properties into props
if(props==None):props=readProperties()
#start a thread to sync with the trust fabric
thread.start_new_thread(syncTrust, ())