コード例 #1
0
def registerApp(fileName):
    import AccessGrid.Toolkit as Toolkit
    app = Toolkit.CmdlineApplication()
    appdb = app.GetAppDatabase()

    fn = os.path.basename(fileName)

    exeCmd = sys.executable + " " + fn + " -a %(appUrl)s"

    # Call the registration method on the applications database
    #appdb.RegisterApplication("Shared Covise",
    #                          "application/x-ag-shared-covise",
    #                          "sharedcovise",
    #                          {"Open" : exeCmd },
    #                          [fn], os.getcwd())
    # old init have to be changed soon
    uad = Platform.GetUserAppPath()
    src = os.path.abspath(fn)
    dest = os.path.join(uad, fn)

    exeCmd = sys.executable + " \"" + dest + "\" -a %(appUrl)s"
    print("hallo" + src + " to " + dest)
    try:
        shutil.copyfile(src, dest)
    except IOError:
        print "could not copy app into place"
        sys.exit(1)

    # Call the registration method on the applications database
    appdb.RegisterApplication("Shared Covise", "application/x-ag-covise",
                              "sharedcovise", {"Open": exeCmd})
コード例 #2
0
    def saveConfig(self):

        userapp = Platform.GetUserAppPath()
        configFileName = userapp + "\\SharedCovise.config"
        configFile = None
        try:
            configFile = file(configFileName, 'w')
        except:
            print "could no save config file"
        if configFile != None:
            configFile.write(self.hostName + "\n")
            configFile.write(str(self.serverPort) + "\n")
コード例 #3
0
    def __init__(self, arg, url, log=None):
        wxApp.__init__(self, arg)
        """
        This is the constructor for the Shared Covise.
        """
        # Initialize state in the shared covise
        self.url = url
        self.eventQueue = Queue.Queue(5)
        self.log = log
        self.masterId = None
        self.numSteps = 0
        self.hostName = "vision.rus.uni-stuttgart.de"
        self.serverPort = 31098
        self.masterSocket = None

        # Get a handle to the application object in the venue
        self.log.debug("Getting application proxy (%s).", url)
        self.appProxy = Client.Handle(self.url).GetProxy()

        # Join the application object, get a private ID in response
        self.log.debug("Joining application.")
        (self.publicId, self.privateId) = self.appProxy.Join()

        # Get the information about our Data Channel
        self.log.debug("Retrieving data channel information.")
        (self.channelId, esl) = self.appProxy.GetDataChannel(self.privateId)

        # Connect to the Data Channel, using the EventClient class
        # The EventClient class is a general Event Channel Client, but since
        # we use the Event Channel for a Data Channel we can use the
        # Event Client Class as a Data Client. For more information on the
        # Event Channel look in AccessGrid\EventService.py
        # and AccessGrid\EventClient.py
        self.log.debug("Connecting to data channel.")
        self.eventClient = EventClient(self.privateId, esl, self.channelId)
        self.eventClient.start()
        self.eventClient.Send(ConnectEvent(self.channelId, self.privateId))

        # Register callbacks with the Data Channel to handle incoming
        # events.
        self.log.debug("Registering for events.")
        self.eventClient.RegisterCallback(SharedCovEvent.MASTER,
                                          self.RecvMaster)
        self.eventClient.RegisterCallback(SharedCovEvent.CLEAN,
                                          self.CleanCovise)

        self.masterHost = ""
        self.masterPort = 0
        self.masterHost = self.appProxy.GetData(self.privateId,
                                                SharedCovKey.MASTERHOST)
        self.masterPort = self.appProxy.GetData(self.privateId,
                                                SharedCovKey.MASTERPORT)
        self.frame.SetMasterHost(self.masterHost + ":" + str(self.masterPort))

        self.log.debug("fit.")

        self.log.debug("SharedCovise V1.0")

        # read configueation file
        userapp = Platform.GetUserAppPath()
        configFileName = userapp + "\\SharedCovise.config"
        configFile = None
        try:
            configFile = file(configFileName, 'r')
        except:
            print "could no open config file"
        if configFile != None:
            entry = configFile.readline(200)
            if entry != "":
                self.hostName = entry.rstrip("\n")
            entry = configFile.readline(200)
            if entry != "":
                self.serverPort = int(entry)

        self.frame.SetPort(self.serverPort)
        self.frame.SetHost(self.hostName)

        if self.masterHost == self.hostName and self.serverPort == self.serverPort:
            #connect to our Daemon and find out if covise is still running
            message = "check"
            try:
                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                s.connect((HOST, PORT))
                s.send(message)
                self.masterSocket = s
                self.appProxy.SetData(self.privateId, SharedCovKey.MASTERHOST,
                                      self.hostName)
                self.appProxy.SetData(self.privateId, SharedCovKey.MASTERPORT,
                                      self.serverPort)
                self.eventClient.Send(
                    Event(SharedCovEvent.MASTER, self.channelId,
                          (self.publicId, self.publicId)))
                Thread(target=self.monitorMaster).start()
            except:
                self.appProxy.SetData(self.privateId, SharedCovKey.MASTERHOST,
                                      "")
                self.appProxy.SetData(self.privateId, SharedCovKey.MASTERPORT,
                                      0)
                self.eventClient.Send(
                    Event(SharedCovEvent.MASTER, self.channelId,
                          (self.publicId, self.publicId)))
                print "could not connect to AccessGridDaemon\n"