Esempio n. 1
0
    def setCredentials(self, request):
        if self.username:
            username = self.username
            password = self.password
        elif self.params.getUsername():
            username = self.params.getUsername()
            password = self.params.getPassword()
        else:
            return

        encoding = Base64.encodeBase64String(String(username + ':' + password).getBytes('ISO-8859-1'))
        request.addHeader('Authorization', 'Basic ' + encoding)
    def set_credentials(self, request):
        if self.username:
            username = self.username
            password = self.password
        elif self.params.getUsername():
            username = self.params.getUsername()
            password = self.params.getPassword()
        else:
            return

        encoding = Base64.encodeBase64String(String(username + ':' + password).getBytes())
        request.addHeader('Authorization', 'Basic ' + encoding)
Esempio n. 3
0
def test_JCD(im, silence=False):
    """ Testing: Joint Color Descriptor (JCD) """
    if not silence:
        print ""
        print "JCD:"
    jcd = JCD()
    jcd.extract(im)
    return (
        "n/a", #jcd.getStringRepresentation()
        Base64.encodeBase64String(
            jcd.getByteArrayRepresentation()),
        ParallelSolrIndexer.arrayToString(
            BitSampling.generateHashes(
                jcd.getDoubleHistogram())))
Esempio n. 4
0
def test_PHOG(im, silence=False):
    """ Testing: Pyramidal Histogram of Gradient (PHOG) Descriptor """
    if not silence:
        print ""
        print "PHOG:"
    phog = PHOG()
    phog.extract(im)
    return (
        "n/a", # phog.getStringRepresentation()
        Base64.encodeBase64String(
            phog.getByteArrayRepresentation()),
        ParallelSolrIndexer.arrayToString(
            BitSampling.generateHashes(
                phog.getDoubleHistogram())))
Esempio n. 5
0
def test_edge_histogram(im, silence=False):
    """ Testing: edge histogram """
    if not silence:
        print ""
        print "Edge Histogram:"
    edgehist = EdgeHistogram()
    edgehist.extract(im)
    return (
        edgehist.getStringRepresentation(),
        Base64.encodeBase64String(
            edgehist.getByteArrayRepresentation()),
        ParallelSolrIndexer.arrayToString(
            BitSampling.generateHashes(
                edgehist.getDoubleHistogram())))
Esempio n. 6
0
def test_color_layout(im, silence=False):
    """ Testing: color layout """
    if not silence:
        print ""
        print "Color Layout:"
    colorlay = ColorLayout()
    colorlay.extract(im)
    return (
        colorlay.getStringRepresentation(),
        Base64.encodeBase64String(
            colorlay.getByteArrayRepresentation()),
        ParallelSolrIndexer.arrayToString(
            BitSampling.generateHashes(
                colorlay.getDoubleHistogram())))
Esempio n. 7
0
def test_opponent_histogram(im, silence=False):
    """ Testing: opponent histogram """
    # sb.append(arrayToString(BitSampling.generateHashes(feature.getDoubleHistogram())));
    if not silence:
        print ""
        print "Opponent Histogram:"
    opphist = OpponentHistogram()
    opphist.extract(im)
    return (
        opphist.getStringRepresentation(),
        Base64.encodeBase64String(
            opphist.getByteArrayRepresentation()),
        ParallelSolrIndexer.arrayToString(
            BitSampling.generateHashes(
                opphist.getDoubleHistogram())))
Esempio n. 8
0
 def set_basic_credentials(self, request):
     credentials = self.get_credentials()
     encoding = Base64.encodeBase64String(
         String(credentials["username"] + ':' +
                credentials["password"]).getBytes())
     request.addHeader('Authorization', 'Basic ' + encoding)