예제 #1
0
파일: daemon.py 프로젝트: arnike/Wenix
 def download(self, ip_addr='127.0.0.1'):
     name = re.search("/([^/]+)$", self.full_path).group(1)
     
     files = os.listdir(FTP_FILES_DIR % '')
     for file in files:
         filename = FTP_FILES_DIR % file
         if os.path.islink(filename):
             if int(time.time()) - int(os.lstat(filename)[ST_CTIME]) > \
                 FILE_STORE_PERIOD:
                 os.remove(filename)
             elif os.readlink(filename) == self.full_path.encode("utf8"):
                 return file
     
     # Writing to the traffic log
     if not self.user.is_superuser:
         Traffic.objects.create(username=self.ftp_user.username,
                                filename=self.path,
                                transfertype='RETR',
                                transfersize=os.stat(self.full_path).st_size,
                                transferhost=ip_addr,
                                transfertime='1.00')
     
     while True:
         self.full_name = "%s_%s" % (gen_random_str(5), name)
         if not os.path.isfile(FTP_FILES_DIR % self.full_name):
             os.symlink(self.full_path, FTP_FILES_DIR % self.full_name)
             render_to_task("rm -f %s" % (FTP_FILES_DIR % self.full_name), "now+4hour")
             return self.full_name
예제 #2
0
파일: views.py 프로젝트: arnike/Wenix
def user_agents_statistics(lines):
    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 400, 400)
    data = [(line[0], [[0, line[1]]]) for line in lines]
    options = {
        'background': {
            'hide': True,
        },
        'legend': {
            'hide': True,
        },
        'padding': {
            'left': 70,
            'right': 10,
            'top': 0,
            'bottom': 0,
        },

    }
    chart = pycha.pie.PieChart(surface, options)
    chart.addDataset(data)
    chart.render()
    name = gen_random_str(5)
    surface.write_to_png(PIE_PATH % name)
    render_to_task("rm -f %s" % (PIE_PATH % name), "now+5minutes")
    return "/media/stat/%s.png" % name
예제 #3
0
파일: config.py 프로젝트: arnike/Wenix
 def update(self):
     serial = self.config[self.zone_name]['SOA']['params']['serial']
     self.config[self.zone_name]['SOA']['params']['serial'] = str(int(serial)+1)
     if self.save():
         render_to_task("rndc reload %s" % self.zone_name)
         return 1
     else:
         log(8, "ZoneConfig - serial update", "Failed to update serial for a zone %s" % self.zone_name)
         return 0
예제 #4
0
파일: daemon.py 프로젝트: arnike/Wenix
 def reconfig(self):
     render_to_task("/usr/bin/kill -HUP `/sbin/pidof %s`" % self.name_lower)
예제 #5
0
파일: daemon.py 프로젝트: arnike/Wenix
 def start(self):
     render_to_task(self.ctrl_script["start"])
     time.sleep(1)
     return self.status