Exemple #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])
Exemple #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])
Exemple #3
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])
Exemple #4
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])
Exemple #5
0
    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])
Exemple #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])
Exemple #7
0
    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])
Exemple #8
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])
Exemple #9
0
        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():
Exemple #10
0
        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():