コード例 #1
0
    def sethmac(self, lhmac=None):

        localfile = os.path.join(self.lootpath, self.luuid, "hmac")
        tlocalfile = tmpname.get(localfile)

        f = open(tlocalfile[1], "w")
        f.write(lhmac)
        f.close()

        tools.rename(tlocalfile[1], tlocalfile[0])
コード例 #2
0
    def setlastseen(self):

        localfile = os.path.join(self.lootpath, self.luuid, "last")
        tlocalfile = tmpname.get(localfile)
        f = open(tlocalfile[1], "w")
        t = datetime.datetime.now()
        f.write(str(time.mktime(t.timetuple())))
        f.close()
        if os.path.exists(tlocalfile[1]):
            tools.rename(tlocalfile[1], tlocalfile[0])
コード例 #3
0
ファイル: loot.py プロジェクト: duongbaoduy/Forban
    def setlastseen(self):

        localfile = os.path.join(self.lootpath, self.luuid, "last")
        tlocalfile = tmpname.get(localfile)
        f = open(tlocalfile[1], "w")
        t = datetime.datetime.now()
        f.write(str(time.mktime(t.timetuple())))
        f.close()
        if os.path.exists(tlocalfile[1]):
            tools.rename(tlocalfile[1], tlocalfile[0])
コード例 #4
0
ファイル: loot.py プロジェクト: duongbaoduy/Forban
    def sethmac(self, lhmac=None):

        localfile = os.path.join(self.lootpath, self.luuid, "hmac")
        tlocalfile = tmpname.get(localfile)

        f = open(tlocalfile[1], "w")
        f.write(lhmac)
        f.close()

        tools.rename(tlocalfile[1], tlocalfile[0])
コード例 #5
0
ファイル: index.py プロジェクト: jngrt/Forban
    def save(self, value=None, filepath=None):
        if value is None:
            return False
        if filepath is None:
            return False

        tlocalfile = tmpname.get(filepath, suff=str(os.getpid()))

        f = open(tlocalfile[1], "w")
        f.write(value)
        f.close()

        tools.rename(tlocalfile[1], tlocalfile[0])
コード例 #6
0
    def setname(self, lname):

        localfile = os.path.join(self.lootpath, self.luuid, "name")
        tlocalfile = tmpname.get(localfile)

        f = open(tlocalfile[1], "w")
        f.write(lname)
        f.close()

        tools.rename(tlocalfile[1], tlocalfile[0])

        # self is added for the same forban doing the announce
        # and the discovery

        myid = fid.manage(dynpath=self.dynpath)
        if myid.get() == self.luuid:
            localfile = os.path.join(self.lootpath, self.luuid, "self")
            tlocalfile = tmpname.get(localfile)
            f = open(tlocalfile[1], "w")
            f.write("")
            f.close()
            tools.rename(tlocalfile[1], tlocalfile[0])
コード例 #7
0
ファイル: index.py プロジェクト: Joneseh92/Forban
    def save (self, value=None, filepath=None):
        if value is None:
            return False
        if filepath is None:
            return False

        tlocalfile = tmpname.get(filepath, suff=str(os.getpid()))

        f = open(tlocalfile[1], "w")
        f.write(value)
        f.close()

        tools.rename(tlocalfile[1], tlocalfile[0])
コード例 #8
0
ファイル: loot.py プロジェクト: duongbaoduy/Forban
    def setname(self, lname):

        localfile = os.path.join(self.lootpath, self.luuid, "name")
        tlocalfile = tmpname.get(localfile)

        f = open(tlocalfile[1], "w")
        f.write(lname)
        f.close()

        tools.rename(tlocalfile[1], tlocalfile[0])

        # self is added for the same forban doing the announce
        # and the discovery

        myid = fid.manage(dynpath=self.dynpath)
        if myid.get() == self.luuid:
            localfile = os.path.join(self.lootpath, self.luuid, "self")
            tlocalfile = tmpname.get(localfile)
            f = open(tlocalfile[1], "w")
            f.write("")
            f.close()
            tools.rename(tlocalfile[1], tlocalfile[0])
コード例 #9
0
ファイル: fetch.py プロジェクト: break123/Forban
        return False
    else:
        pass

    (lpath, lfile) = os.path.split(localfile)

    if not os.path.isdir(lpath) and not (lpath ==''):
        os.makedirs(lpath)

    # as url fetch is part of the Forban protocol interface
    # the Content-Disposition MUST be present even if it's
    # not used right now. The interface is used as file transfert
    # so the Content-Disposition is a requirement for any other
    # HTTP clients

    tlocalfile = tmpname.get(localfile)

    if r.info().has_key('Content-Disposition'):
        f = open (tlocalfile[1], "w")
        try:
            shutil.copyfileobj(r.fp,f)
        except:
            return False
        f.close()
        if os.path.exists(tlocalfile[1]):
            tools.rename(tlocalfile[1], tlocalfile[0])
        return True
    else:
        return False

def managetest():
コード例 #10
0
ファイル: fetch.py プロジェクト: uriel/Forban
        return False
    else:
        pass

    (lpath, lfile) = os.path.split(localfile)

    if not os.path.isdir(lpath) and not (lpath ==''):
        os.makedirs(lpath)

    # as url fetch is part of the Forban protocol interface
    # the Content-Disposition MUST be present even if it's
    # not used right now. The interface is used as file transfert
    # so the Content-Disposition is a requirement for any other
    # HTTP clients

    tlocalfile = tmpname.get(localfile)

    if r.info().has_key('Content-Disposition'):
        f = open (tlocalfile[1], "w")
        try:
            shutil.copyfileobj(r.fp,f)
        except:
            return False
        f.close()
        if os.path.exists(tlocalfile[1]):
            tools.rename(tlocalfile[1], tlocalfile[0])
        return True
    else:
        return False

def managetest():