Esempio n. 1
0
    def inv_session(self, line=None):
        """Return the current invocation session id, create one if necessary.
        Parameters are ignored
        """
        global user_id, token, user_profile, inv_client, inv_session, endpoint

        if inv_client is None:
            if token is None:
                user_msg("You are not currently logged in. Using anonymous,"
                             " unauthenticated access")
            try:
                inv_client = InvocationClient( url = endpoint['invocation'], token = token)
                sess_id = "nrtv_" + str(int(time.time())) + "_" + ''.join(random.choice(string.hexdigits) for x in range(6))
                inv_session = inv_client.start_session(sess_id)
                if inv_session == sess_id:
                    user_msg("New anonymous session created : %s"
                                 % inv_session)
                else:
                    user_msg("New authenticated session created "
                                 "for user %s" % user_id)
            except Exception, e:
                user_msg("Error initializing a new invocation service "
                             "client: %s" % e)
Esempio n. 2
0
    def inv_session(self, line=None):
        """Return the current invocation session id, create one if necessary.
        Parameters are ignored
        """
        global user_id, token, user_profile, inv_client, inv_session, endpoint

        if inv_client is None:
            if token is None:
                user_msg("You are not currently logged in. Using anonymous,"
                             " unauthenticated access")
            try:
                inv_client = InvocationClient( url = endpoint['invocation'], token = token)
                sess_id = "nrtv_" + str(int(time.time())) + "_" + ''.join(random.choice(string.hexdigits) for x in range(6))
                inv_session = inv_client.start_session(sess_id)
                if inv_session == sess_id:
                    user_msg("New anonymous session created : %s"
                                 % inv_session)
                else:
                    user_msg("New authenticated session created "
                                 "for user %s" % user_id)
            except Exception, e:
                user_msg("Error initializing a new invocation service "
                             "client: %s" % e)