Exemplo n.º 1
0
    def __init__(self):

        self.returnMetadata = True
        self.getAllSubsCount = 0
        self.getAllSubsParametersHistory = list()

        self.getMetadataCount = 0
        self.getMetadataParametesHistory = list()

        self.updateSubtitleCount = 0
        self.updateSubtitleParameterHistory = list()

        self.commitCount = 0

        s1 = SubtitleInfo("eng", os.path.join(RES_DIR,"fake0.srt"))
        s1.computeChecksum()
        s2 = SubtitleInfo("rus", os.path.join(RES_DIR,"fake1.srt"))
        s2.computeChecksum()

        self.returnSubs = {
                            "eng" : s1,
                            "rus" : s2
                            }

        self.insertMetadataCount = 0
        self.insertMetadataParameters = list()
        self.nextKeypair = None
    def setUpDB(self):
        try:
            self.richMetadata_db = self.session.open_dbhandler(
                NTFY_RICH_METADATA)

            #add some metadata
            self.mdto = MetadataDTO(self.anotherpermid, self.testInfohash)
            subtitle1 = SubtitleInfo("nld", self.sub1)
            subtitle1.computeChecksum()
            subtitle2 = SubtitleInfo("eng", os.path.join(RES_DIR, "fake0.srt"))
            subtitle2.computeChecksum()
            self.mdto.addSubtitle(subtitle1)
            self.mdto.addSubtitle(subtitle2)

            self.mdto.sign(self.another_keypair)

            self.richMetadata_db.insertMetadata(self.mdto)

            #hisoermid has the nld subtitle but doesn't have the english one
            self.richMetadata_db.updateSubtitlePath(self.mdto.channel,
                                                    self.mdto.infohash, "eng",
                                                    None)

        except:
            print_exc()
Exemplo n.º 3
0
    def testChecksums(self):
        path = os.path.join(RES_DIR, PATH_TO_SRT)
        sub = SubtitleInfo("ita", path)
        #I know from the outside the the correct sha1 is
        # eb8ada2a2094675ea047c27207e449fbfce04e85
        sha1Hasher = hashlib.sha1()
        with codecs.open(path, "rb", "utf-8") as subFile:
            sha1Hasher.update(subFile.read())
        expectedChecksum = sha1Hasher.digest()

        sub.computeChecksum()

        self.assertEquals(expectedChecksum, sub.checksum)

        self.assertTrue(sub.verifyChecksum())
Exemplo n.º 4
0
 def testChecksums(self):
     path = os.path.join(RES_DIR,PATH_TO_SRT)
     sub = SubtitleInfo("ita",path)
     #I know from the outside the the correct sha1 is
     # eb8ada2a2094675ea047c27207e449fbfce04e85
     sha1Hasher = hashlib.sha1()
     with codecs.open(path, "rb", "utf-8") as subFile:
         sha1Hasher.update(subFile.read())
     expectedChecksum = sha1Hasher.digest()
     
     
     sub.computeChecksum()
     
     self.assertEquals(expectedChecksum,
                       sub.checksum)
     
     self.assertTrue(sub.verifyChecksum())
 def setupDB(self,nickname):
     TestChannels.setupDB(self,nickname)
     try:
         self.richMetadata_db = self.session.open_dbhandler(NTFY_RICH_METADATA)
         #add some metadata for torrents (they are defined in TestChannels.setupDB()
         self.mdto = MetadataDTO(self.hispermid, self.infohash1)
         subtitle1 = SubtitleInfo("nld", os.path.join(RES_DIR,"fake.srt"))
         subtitle1.computeChecksum()
         
         subtitle2 = SubtitleInfo("eng", os.path.join(RES_DIR, "fake0.srt"))
         subtitle2.computeChecksum()
         self.mdto.addSubtitle(subtitle1)
         self.mdto.addSubtitle(subtitle2)
         
         self.mdto.sign(self.his_keypair)
         
         self.richMetadata_db.insertMetadata(self.mdto)
     except:
         print_exc()
    def setupDB(self, nickname):
        TestChannels.setupDB(self, nickname)
        try:
            self.richMetadata_db = self.session.open_dbhandler(
                NTFY_RICH_METADATA)
            #add some metadata for torrents (they are defined in TestChannels.setupDB()
            self.mdto = MetadataDTO(self.hispermid, self.infohash1)
            subtitle1 = SubtitleInfo("nld", os.path.join(RES_DIR, "fake.srt"))
            subtitle1.computeChecksum()

            subtitle2 = SubtitleInfo("eng", os.path.join(RES_DIR, "fake0.srt"))
            subtitle2.computeChecksum()
            self.mdto.addSubtitle(subtitle1)
            self.mdto.addSubtitle(subtitle2)

            self.mdto.sign(self.his_keypair)

            self.richMetadata_db.insertMetadata(self.mdto)
        except:
            print_exc()
Exemplo n.º 7
0
    def setUpDB(self):
        try:
            self.richMetadata_db = self.session.open_dbhandler(NTFY_RICH_METADATA)

            #add some metadata
            self.mdto = MetadataDTO(self.anotherpermid, self.testInfohash)
            subtitle1 = SubtitleInfo("nld", self.sub1)
            subtitle1.computeChecksum()
            subtitle2 = SubtitleInfo("eng", os.path.join(RES_DIR, "fake0.srt"))
            subtitle2.computeChecksum()
            self.mdto.addSubtitle(subtitle1)
            self.mdto.addSubtitle(subtitle2)
            
            self.mdto.sign(self.another_keypair)
            
            self.richMetadata_db.insertMetadata(self.mdto)
            
            
            
            #hisoermid has the nld subtitle but doesn't have the english one
            self.richMetadata_db.updateSubtitlePath(self.mdto.channel,self.mdto.infohash,"eng",None)
            
        except:
            print_exc()
    def __init__(self):

        self.returnMetadata = True
        self.getAllSubsCount = 0
        self.getAllSubsParametersHistory = list()

        self.getMetadataCount = 0
        self.getMetadataParametesHistory = list()

        self.updateSubtitleCount = 0
        self.updateSubtitleParameterHistory = list()

        self.commitCount = 0

        s1 = SubtitleInfo("eng", os.path.join(RES_DIR, "fake0.srt"))
        s1.computeChecksum()
        s2 = SubtitleInfo("rus", os.path.join(RES_DIR, "fake1.srt"))
        s2.computeChecksum()

        self.returnSubs = {"eng": s1, "rus": s2}

        self.insertMetadataCount = 0
        self.insertMetadataParameters = list()
        self.nextKeypair = None