def putService(self, key, value):
        '''
            Puts the key and value in to the DHT depending on the parameters
        '''
        #If the key is in the list of services, it means this is a call to add
        #a service ID under its service name
        if key in self.services:
            serviceIDs = self.getProvidersForServiceTypes(key)

            #If this is the first time a service is being registered under this type
            #create a new list, else append to the list and put in the DHT
            if serviceIDs is None:
                print("First entry for {0} is service id: {1}".format(key, value))
                serviceIDs = [value]
            else:
                serviceIDs = JavaScriptSerializer().DeserializeObject(serviceIDs)
                serviceIDs = list(serviceIDs)
                serviceIDs.append(value)
                print("Appending entry {0} in service type: {1}".format(value, key))

            #Add the current service id under the list of services for its category
            self.group.DHTPut(key, json.dumps(serviceIDs))

            return "Service ID {0} added to list of {1}".format(value, key)

        #The key-value pair passed in is the service id and the corresponding
        #service object
        else:
            self.group.DHTPut(key, value)
            print("Information about Service ID {0} has been stored in the DHT {1}".format(key, value))
            return "Information about Service ID {0} has been stored in the DHT {1}".format(key, value)
Ejemplo n.º 2
0
    def send_job_results(self, results, job_id):
        self.key_exchange()

        if type(results) == dict:
            results = JavaScriptSerializer().Serialize(results)
        elif hasattr(results, '__serialize__'):
            results = JavaScriptSerializer().Serialize(results.__serialize__())

        encrypted_results = self.crypto.Encrypt(results)
        job_url = Uri(urljoin(self.jobs_url, job_id))

        while True:
            try:
                self.requests.post(job_url, payload=encrypted_results)
                return
            except Exception as e:
                if DEBUG:
                    print "Error performing sending job results: " + str(e)
                    print_traceback()

            Thread.Sleep(self.client.SLEEP)
Ejemplo n.º 3
0
                
                if (data.success) {
                    document.getElementById('assignment-' + params.sheep).innerHTML = data.shepherdName
            
                    selectElt.selectedIndex = 0;
                }
            }
        }
        
        </script>
        
        """
elif model.HttpMethod == "post" and Data.submit == '1':
    try:
        shepherd = model.GetPerson(Data.shepherd)
        sheep = model.GetPerson(Data.sheep)

        model.AddExtraValueIntFamily(sheep.PeopleId, ShepheredExtraValueName,
                                     shepherd.PeopleId)

        out = {'success': True, 'shepherdName': shepherd.Name}

    except:
        out = {'success': False}

    print "<!-- >>>>>DATA>" + JavaScriptSerializer().Serialize(
        out) + "<DATA<<<<< -->"

else:
    print """It seems you came across this in a way that won't work.  To view or make shepherding assignments, go to a profile or search.  Then, go to 
    the blue toolbar's <pre></></pre> menu and Select the Assign Shepherd report."""