コード例 #1
0
ファイル: timer.py プロジェクト: nellobrunelli/Django
def filter_folder(path):
    def get_list(path):
        """returns a list of files in a directory tree"""
        l = []
        for item in walk(path):
            for filenames in item[2]:
                # include a test to verify that the files are NC?
                l.append(item[0] + sep + filenames)

        return l

    for nc_file in get_list(path):
        f = open(nc_file)
        nc_string = f.read()
        f.close()
        nc = nc_parser(nc_string)
        header = nc.header()
        if header.has_key("Duration"):
            duration = int(round(float(header["Duration"]), 0))
            if header.has_key("Start time"):
                start = header["Start time"]
                ticked = True
            else:
                start = next_start_time
                ticked = False
        else:
            duration = total(nc_file)
            extend_header(nc_file, {"Duration": str(duration)})
コード例 #2
0
ファイル: models.py プロジェクト: Martin10015946/Django
 def set_ready(self):
     draw_nc(self.path, 
             self.preview_path,
             str(self.get_duration()), 
             grey_background=True)
     extend_header(self.path,{'Ready':'True'})
     reduce_header(self.path,'Start time')
コード例 #3
0
ファイル: models.py プロジェクト: Martin10015946/Django
 def get_preview(self, force=False):
     if not self.is_preview_cached() or force:
         if force: 
             extend_header(self.path,{'Ready':'False'})
             reduce_header(self.path, 'Start time')
             self.header.pop('Start time')
         draw_nc(self.path, 
                 self.preview_path, 
                 str(self.get_duration()),
                 grey_lines=self.is_transfered())
     return self.board_url
コード例 #4
0
ファイル: models.py プロジェクト: Martin10015946/Django
 def get_duration(self):
     '''Return the running time of the file in minutes (int)
     Either getting it from the header of the file "Duration" key,
     or calculating it with timer.py
     '''
     if 'Duration' in self.header:
         return int(round(float(self.header['Duration']),0))
     else: # stamp the file with duration
         try:
             dur = timer.total(self.path)
             dur = ((dur * settings.BOARDS_BREAK) / 100) + dur
             dur = str(int(dur))
         except:
             dur = '0'
         extend_header(self.path,{'Duration':str(dur)})
         return int(dur)