Ejemplo n.º 1
0
def draw_nc(path, image_path, duration, grey_background=False, grey_lines=False):
    """
        Implement the convention that we render Face B on two 
        face sheets and Face A on single face sheet.

        Also: failsafe, render a blank board if it rendering 
        bugs for some reason.
    """
    
    f = open(path)
    s = f.read()
    f.close()
    
    boards = list_boards(s)
    bnr = 1
    for board in boards :
        try:
            nc = nc_parser(board)
            list_of_faces = nc.faces()
            # pick the right face to render
            if len(list_of_faces) == 2:
                face = list_of_faces[1]
            else:
                face = list_of_faces[0]
            draw_face(face, image_path, duration, grey_background, grey_lines)
        except: 
            # it was too hard to draw a blank rectangle will do
            draw_empty_face(image_path, duration, grey_background)
        bnr += 1
Ejemplo n.º 2
0
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)})
Ejemplo n.º 3
0
    def __init__(self, path):
        self.path = path
        
        us_name = os.path.basename(self.path).replace(' ', '_')

        self.preview_path = settings.BOARDS_CACHE + os.sep
        self.preview_path += us_name + '.jpg' 
        
        self.board_url = 'http://169.254.184.4/img/boards/' + os.path.basename(self.preview_path)
        
        try:
            f = open(self.path)
            ncs = f.read()
            f.close()
            nc = nc_parser(ncs)
            self.header = nc.header()
        except:
            self.header = {}