示例#1
0
def init_product():
    status.register_build_status_handler()

    project = ARGUMENTS.get('project', 'all')
    projects = get_projects()
    project_deps = []
    project_deps_loaded = {}

    if project == 'all':
        project_deps = projects.keys()
    else:
        project_deps.append(project)

    target = ARGUMENTS.get('target', 'native')
    if target != 'native':
        toolchain_dir = os.path.join(Dir('#').abspath, 'site_scons')    
        toolchain_name = ARGUMENTS.get('target')
        assert toolchains.load_toolchain(toolchain_dir, toolchain_name) == True,\
            "Toolchain '%s' not found." % toolchain_name

    env = DefaultEnvironment()
    
    init_platform(env)
    env.Append(CPPDEFINES={'PRODUCT_NAME' : current_project_name()})

    #
    # Disable alternate pretty strings for verbose output.
    #
    if not ARGUMENTS.get('verbose'):
        colors.colorize(env)

    #
    # Configure the default product environment
    #
    default_include_dirs = [Dir('#').abspath]
    env['CPPPATH'] = default_include_dirs
    env['CPATH'] = default_include_dirs

    debug = ARGUMENTS.get('debug', 0)
    if int(debug): 
        variant = 'debug'
    else:
        variant = 'release'

    variant_base_dir = os.path.join(Dir('#').abspath, BUILD_DIR, target, variant)
    env['VARIANT_BASE_DIR'] = variant_base_dir
    for p in project_deps:
        if p not in project_deps_loaded:
            project_deps_loaded[p] = True
            SConscript(os.path.join(projects[p], 'SConscript'), 
                       variant_dir=os.path.join(variant_base_dir, '.obj', p), 
                       exports = ['env', 'project_deps'],
                       duplicate=0)

    #
    # Add tags convenience target to build ctags file at product root.
    #
    phony_target('tags', 'ctags -R --c++-kinds=+p --fields=+iaS --extra=+qf ' + Dir('#').abspath)

    Clean('.', BUILD_DIR)
示例#2
0
def init_product():
    status.register_build_status_handler()

    project = ARGUMENTS.get('project', 'all')
    projects = get_projects()
    project_deps = []
    project_deps_loaded = {}

    if project == 'all':
        project_deps = projects.keys()
    else:
        project_deps.append(project)

    target = ARGUMENTS.get('target', 'native')
    if target != 'native':
        toolchain_dir = os.path.join(Dir('#').abspath, 'site_scons')    
        toolchain_name = ARGUMENTS.get('target')
        assert toolchains.load_toolchain(toolchain_dir, toolchain_name) == True,\
            "Toolchain '%s' not found." % toolchain_name

    env = DefaultEnvironment()
    
    init_platform(env)
    env.Append(CPPDEFINES={'PRODUCT_NAME' : current_project_name()})

    #
    # Disable alternate pretty strings for verbose output.
    #
    if not ARGUMENTS.get('verbose'):
        colors.colorize(env)

    #
    # Configure the default product environment
    #
    default_include_dirs = [Dir('#').abspath]
    env['CPPPATH'] = default_include_dirs
    env['CPATH'] = default_include_dirs

    debug = ARGUMENTS.get('debug', 0)
    if int(debug): 
        variant = 'debug'
    else:
        variant = 'release'

    variant_base_dir = os.path.join(Dir('#').abspath, BUILD_DIR, target, variant)
    env['VARIANT_BASE_DIR'] = variant_base_dir
    for p in project_deps:
        if p not in project_deps_loaded:
            project_deps_loaded[p] = True
            SConscript(os.path.join(projects[p], 'SConscript'), 
                       variant_dir=os.path.join(variant_base_dir, '.obj', p), 
                       exports = ['env', 'project_deps'],
                       duplicate=0)

    #
    # Add tags convenience target to build ctags file at product root.
    #
    phony_target('tags', 'ctags -R --c++-kinds=+p --fields=+iaS --extra=+qf ' + Dir('#').abspath)

    Clean('.', BUILD_DIR)
示例#3
0
    def loop(self):
        self.connect_server()
        while not self.quit_loop:
            try:
                to_read, _, _ = select.select([self.connection], [], [], 1)
            except select.error as err:
                print(
                    colorize("Select Error: {}\n\tReconnect...".format(err),
                             'red', 'shell'))
                self.reconnect()
                continue

            if self.last_pong + self.widelands['ping']['interval'] < time.time(
            ) and not self.widelands['ping']['pending']:
                self.try_ping()

            if self.last_ping + self.widelands['ping']['timeout'] < time.time(
            ):
                print(
                    colorize(
                        "Ping timeout after {} seconds. Reconnect...".format(
                            self.widelands['ping']['timeout']), 'red',
                        'shell'))
                self.reconnect()
                continue

            if to_read:
                self.process_input()

            with self.lock:
                while not self.queue.empty():
                    self.send_message(self.queue.get(), self.events)
                    self.queue.task_done()
示例#4
0
 def roster_updated(self,item=None):
     if not item:
         print colorize('U',"My roster:")
         for item in self.roster.get_items():
             self.print_roster_item(item)
     else:
         print "Roster item updated:"
         self.print_roster_item(item)
示例#5
0
文件: main.py 项目: bgizdov/pytodo
 def viewTodos(self):
     """show all todos"""
     print colorize("white", "<<<<<<  ToDo List  >>>>>>")
     i = 0
     for todo in CTodoContainer.container:
         i = i + 1
         todo.view(i)
     print colorize("white", "-------------------------")
示例#6
0
def fmt_commit(cmt):
    hsh = colorize(cmt['id'][:10], 'teal', 'irc')
    author = colorize(cmt['author']['name'], 'bold-green', 'irc')
    message = cmt['message']
    message = message[:MAX_COMMIT_LEN] \
            + ('..' if len(message) > MAX_COMMIT_LEN else '')

    return '{} {}: {}'.format(hsh, author, message)
示例#7
0
def handle_delete_branch(irc, data):
    author = colorize(data['pusher']['name'], 'bold', 'irc')
    action = colorize('deleted', 'red', 'irc')

    branch = data['ref'].split('/')[-1]
    branch = colorize(branch, 'bold-blue', 'irc')

    irc.schedule_message("{} {} {} {}".format(fmt_repo(data), author, action,
                                              branch))
示例#8
0
文件: pyfont.py 项目: haru17/pyfont
def extraction_from_zip():
    try:
        fzip = zipfile.ZipFile('font_file.zip')
        fzip.extractall('font_dir')
        fzip.close()
    except zipfile.BadZipfile:
        colorize("\nThere was an error in the download file.", color="red")
        os.remove('font_file.zip')
        exit()
示例#9
0
 def send(self,msg,nick=ROOM):
     if not msg: return
     try: 
         msg = msg.decode('ascii')
         print colorize('g',"me:"),msg
     except: 
         print "couldn't send:",repr(msg)
         msg = "Sorry, I can't handle unicode"
     for line in (x for x in msg.split("\n") if len(x) > 0):
         self.sock.send("PRIVMSG %s :%s\r\n"%(nick,line))
示例#10
0
def autorespond(obj,body):
    obj.responder.addWords(body)
    if (not obj.name in body) and random() < 0.95: return None
    r = obj.responder.get(body)
    rr = repr(r)
    if rr[rr.find("'")+1:rr.rfind("'")] != r: return None
    blacklist = [BOT_NAME,'!','spawn']
    if len(r.split()) < 2 or any(w in r for w in blacklist): return None
    print colorize('b',"autoresponse:"),rr
    return r
示例#11
0
def autorespond(obj, body):
    obj.responder.addWords(body)
    if (not obj.name in body) and random() < 0.95: return None
    r = obj.responder.get(body)
    rr = repr(r)
    if rr[rr.find("'") + 1:rr.rfind("'")] != r: return None
    blacklist = [BOT_NAME, '!', 'spawn']
    if len(r.split()) < 2 or any(w in r for w in blacklist): return None
    print colorize('b', "autoresponse:"), rr
    return r
示例#12
0
def handle_pull_request(irc, data):
    repo = fmt_repo(data)
    author = colorize(data['sender']['login'], 'bold', 'irc')
    action = fmt_pr_action(data['action'], data['pull_request']['merged'])
    pr_num = colorize('#' + str(data['number']), 'bold-blue', 'irc')
    title = data['pull_request']['title']
    link = short_gh_link(data['pull_request']['html_url'])

    irc.schedule_message('{} {} {} pull request {}: {} ({})'.format(
        repo, author, action, pr_num, title, link))
示例#13
0
 def send(self, msg, nick=ROOM):
     if not msg: return
     try:
         msg = msg.decode('ascii')
         print colorize('g', "me:"), msg
     except:
         print "couldn't send:", repr(msg)
         msg = "Sorry, I can't handle unicode"
     for line in (x for x in msg.split("\n") if len(x) > 0):
         self.sock.send("PRIVMSG %s :%s\r\n" % (nick, line))
示例#14
0
文件: main.py 项目: bgizdov/pytodo
 def deleteTodo(self, num):
     """delete todo by number"""
     length = len(CTodoContainer.container)
     try:
         num = int(num)
     except ValueError:
         print colorize("red", "* You must enter integer value.")
     if num in range(1, length + 1):
         del (CTodoContainer.container[num - 1])
     else:
         print colorize("red", "* You must enter value in 1 to %s" % str(length))
     self.fileChanged = True
示例#15
0
def fmt_pr_action(action, merged):
    if action == 'opened' or action == 'reopened':
        action = colorize(action, 'green', 'irc')
    elif action == 'closed':
        if merged:
            action = colorize('merged', 'purple', 'irc')
        else:
            action = colorize(action, 'red', 'irc')
    else:
        action = colorize(action, 'brown', 'irc')

    return action
示例#16
0
文件: commands.py 项目: Tayyib/uludag
    def print_packages(self, repo):
        from pisi import packagedb
        from colors import colorize

        pkg_db = packagedb.get_db(repo)
        list = pkg_db.list_packages()
        installed_list = ctx.installdb.list_installed()
        list.sort()
        for p in list:
            if p in installed_list:
                print colorize(p, "cyan")
            else:
                print p
示例#17
0
    def connect_server(self):
        print(
            colorize(
                "Connecting to {}:{}".format(
                    self.widelands['server']['address'],
                    self.widelands['server']['port']), 'brown', 'shell'))

        while not self.connection:
            try:
                self.connection = socket.socket(socket.AF_INET,
                                                socket.SOCK_STREAM)
                if self.widelands['server']['ssl']:
                    self.connection = ssl.wrap_socket(
                        self.connection,
                        do_handshake_on_connect=True,
                        suppress_ragged_eofs=True)
                self.connection.connect((self.widelands['server']['address'],
                                         self.widelands['server']['port']))
            except socket.gaierror:
                print(colorize("Couldn't resolve server, check your internet connection." \
                       " Re-attempting in 60 seconds.", 'red', 'shell'))
                self.connection = None
                time.sleep(self.widelands['server']['retry'])
            except ConnectionRefusedError:
                print(colorize("Couldn't connect to server, check your internet connection." \
                       " Re-attempting in 60 seconds.", 'red', 'shell'))
                self.connection = None
                time.sleep(self.widelands['server']['retry'])

        self.last_ping = time.time()
        self.start_time = time.time()
        self.update('admin', 'debug', False)
        self.process_input()

        if self.widelands['server']['sasl'] and self.widelands['server']['ssl']:
            self.post_string('CAP LS 302')

        if not self.widelands['server']['sasl'] and self.widelands['server'][
                'ssl']:
            self.post_string('PASS {}:{}'.format(
                self.widelands['nickserv']['username'],
                self.widelands['nickserv']['password']))

        self.post_string('NICK {}'.format(
            self.widelands['nickserv']['username']))
        self.post_string('USER {} {} {} :{}'.format(
            self.widelands['nickserv']['username'], '0', '*',
            self.widelands['server']['realname']))

        if self.widelands['server']['sasl'] and self.widelands['server']['ssl']:
            self.post_string('CAP REQ :sasl')
示例#18
0
def handle_issue_comment(irc, data):
    repo = fmt_repo(data)
    title = fmt_message(data['issue']['title'], MAX_COMMIT_LEN)
    author = colorize(data['sender']['login'], 'bold', 'irc')
    issue_num = colorize('#' + str(data['issue']['number']), 'bold-blue',
                         'irc')
    issue_link = short_gh_link(data['issue']['html_url'])
    comment_link = short_gh_link(data['comment']['html_url'])
    message = fmt_message(data['comment']['body'])

    irc.schedule_message('{} {} commented on issue {}: {} ({})'.format(
        repo, author, issue_num, title, issue_link))
    irc.schedule_message('{} ({})'.format(message, comment_link))

    print('Issue comment')
    def figure_with_temp_scale(self):
        data = self.h5data.frame(current_frame, 640, 480)
        img = colors.colorize(data, colorMapType)
        rgbImage = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

        # colormap of the bar
        C = colors.get_color_map(colorMapType)
        C = np.squeeze(C)
        C = C[..., ::-1]
        C2 = C / 255.0
        ccm = ListedColormap(C2)

        fig = plt.figure()
        plt.title('Frame: ' + str(current_frame) + '   Max Temp: ' +
                  self.maxtemp())
        bounds = [0, 50, 100]
        im = plt.imshow(rgbImage,
                        cmap=ccm,
                        clim=(self.maxtemp()[:-2], self.mintemp()[:-2]))
        cbar = fig.colorbar(im)
        cbar.ax.minorticks_on()
        limits = cbar.get_clim()
        cbar.set_label('     [$^\circ$' + toggleUnitState + ']',
                       rotation=0)  # 270
        plt.show()
示例#20
0
    def message_received(self,frm,body):
        print colorize('k',frm+':'),body
        if self.log:
            self.write_log(frm,body)

        msg = None
        cmd_match = re.match("(?:%s\s*[:,;:->]+\s*|!)(\w+)"%self.name,body)
        if cmd_match:
            cmd_name = cmd_match.group(1).lower()
            if cmd_name in self.commands:
                cmd = self.commands[cmd_name]
                try:
                    msg = cmd(self,frm,body)
                except Exception, e:
                    print notify('!','r',"Error processing command: "+cmd_name)
                    print e
    def renew_image(self):
        try:
            if current_frame == 1:
                self.figure.tight_layout()

            self.currentFrameDisp.setText('Current Frame: ' +
                                          str(current_frame))

            frame = self.h5data.frame(current_frame, 640, 480)
            minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(frame)
            self.maxTempLabel.setText(
                'Current Max Temp: ' +
                get_temp_with_unit(maxVal, toggleUnitState))
            self.maxTempLocLabel.setText('Max Temp Loc: ' + str(maxLoc))
            self.minTempLabel.setText(
                'Current Min Temp: ' +
                get_temp_with_unit(minVal, toggleUnitState))
            self.minTempLocLabel.setText('Min Temp Loc: ' + str(minLoc))

            img = colors.colorize(frame, colorMapType)
            rgbImage = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

            self.ax = self.figure.add_subplot(111)
            self.ax.clear()
            self.cax = self.ax.imshow(rgbImage)

            self.sl.setValue(current_frame)
            self.currentTimeLabel.setText(
                'Current Time: ' + str(round(((current_frame - 1) / 9.00), 2)))
            cid = self.canvas.mpl_connect('motion_notify_event', self.hover)
        except:
            pass
def to_png(savepath, frame, colormap):
    try:
        bgr = colors.colorize(frame, colormap)
        cv2.imwrite(savepath, bgr)
        print('Saved ' + savepath)
    except:
        print('Error while saving ' + savepath)
    return
示例#23
0
def handle_issue(irc, data):
    repo = fmt_repo(data)
    user = colorize(data['sender']['login'], 'bold', 'irc')

    action = data['action']
    if not action in ['opened', 'closed']:
        return
    action_color = 'red' if action == 'opened' else 'green'
    action = colorize(action, action_color, 'irc')

    issue_num = colorize('#' + str(data['issue']['number']), 'bold-blue',
                         'irc')
    title = data['issue']['title']
    link = short_gh_link(data['issue']['html_url'])

    irc.schedule_message('{} {} {} issue {}: {} ({})'.format(
        repo, user, action, issue_num, title, link))
示例#24
0
 def wrapper(*args, **kwargs):
     startTime = perf_counter()
     func(*args, **kwargs)
     endTime = perf_counter()
     print(
         colorize(
             f"Function '{func.__name__}' took {round(endTime-startTime,2)}secs to execute.",
             Colors.Yellow))
示例#25
0
    def message_received(self, frm, body):
        print colorize('k', frm + ':'), body
        if self.log:
            self.write_log(frm, body)

        msg = None
        cmd_match = re.match("(?:%s\s*[:,;:->]+\s*|!)(\w+)" % self.name, body)
        if cmd_match:
            cmd_name = cmd_match.group(1).lower()
            if cmd_name in self.commands:
                cmd = self.commands[cmd_name]
                try:
                    msg = cmd(self, frm, body)
                except Exception, e:
                    print notify('!', 'r',
                                 "Error processing command: " + cmd_name)
                    print e
示例#26
0
 def post_string(self, message):
     message = "{}\n".format(message)
     print(
         colorize(
             '{} {}> {}'.format(time.strftime(self.time_format),
                                self.widelands['nickserv']['username'],
                                message[:-1]), 'blue', 'shell'))
     self.last_ping = time.time()
     self.connection.send(message.encode('utf-8'))
示例#27
0
def _FormatHeader(line, end=72, mark="-", color=None):
    """Fill a line up to the end column.

  """
    line = (mark * 4) + " " + line + " "
    line += "-" * (end - len(line))
    line = line.rstrip()
    line = colors.colorize(line, color=color)
    return line
示例#28
0
def read_line_from_file(input_file, prompt, n):
    prompt = colorize(f"[{n:3d}] {prompt}", "green")
    sys.stdout.write(prompt)
    line = input_file.readline()

    if line is not None:
        print(line)

    return line
示例#29
0
def handle_force_push(irc, data):
    author = colorize(data['pusher']['name'], 'bold', 'irc')

    before = colorize(data['before'][:10], 'bold-red', 'irc')
    after = colorize(data['after'][:10], 'bold-red', 'irc')

    branch = data['ref'].split('/')[-1]
    branch = colorize(branch, 'bold-blue', 'irc')

    irc.schedule_message("{} {} force-pushed {} from {} to {} ({}):".format(
        fmt_repo(data), author, branch, before, after,
        short_gh_link(data['compare'])))

    commits = fmt_last_commits(data)
    for commit in commits:
        irc.schedule_message(commit)

    print("Force push event")
示例#30
0
def _FormatHeader(line, end=72, mark="-", color=None):
  """Fill a line up to the end column.

  """
  line = (mark * 4) + " " + line + " "
  line += "-" * (end - len(line))
  line = line.rstrip()
  line = colors.colorize(line, color=color)
  return line
示例#31
0
def handle_watch_event(irc, data):
    if data['action'] == 'started':
        message = colorize('has been starred by', 'bold-green', 'irc')
    else:
        print('Watch event: {}'.format(data['action']))
    repo = fmt_repo(data)
    sender = data['sender']['login']
    irc.schedule_message('{} {} {}'.format(repo, message, sender))

    print('Watch event')
示例#32
0
def StartLocalCommand(cmd, _nolog_opts=False, log_cmd=True, **kwargs):
    """Starts a local command.

  """
    if log_cmd:
        if _nolog_opts:
            pcmd = [i for i in cmd if not i.startswith("-")]
        else:
            pcmd = cmd
        print "%s %s" % (colors.colorize("Command:", colors.CYAN), utils.ShellQuoteArgs(pcmd))
    return subprocess.Popen(cmd, shell=False, **kwargs)
示例#33
0
def handle_forward_push(irc, data):
    author = colorize(data['pusher']['name'], 'bold', 'irc')

    num_commits = len(data['commits'])
    num_commits = "{} commit{}".format(num_commits,
                                       's' if num_commits > 1 else '')

    num_commits = colorize(num_commits, 'bold-teal', 'irc')

    branch = data['ref'].split('/')[-1]
    branch = colorize(branch, 'bold-blue', 'irc')

    irc.schedule_message("{} {} pushed {} to {} ({}):".format(
        fmt_repo(data), author, num_commits, branch,
        short_gh_link(data['compare'])))

    commits = fmt_last_commits(data)
    for commit in commits:
        irc.schedule_message(commit)

    print("Push event")
示例#34
0
def StartLocalCommand(cmd, _nolog_opts=False, log_cmd=True, **kwargs):
    """Starts a local command.

  """
    if log_cmd:
        if _nolog_opts:
            pcmd = [i for i in cmd if not i.startswith("-")]
        else:
            pcmd = cmd
        print "%s %s" % (colors.colorize(
            "Command:", colors.CYAN), utils.ShellQuoteArgs(pcmd))
    return subprocess.Popen(cmd, shell=False, **kwargs)
示例#35
0
def handle_status_event(irc, data):
    if data['state'] == 'success':
        color = 'bold-green'
    elif data['state'] == 'error':
        color = 'red'
    elif data['state'] == 'failure':
        color = 'bold-red'
    elif data['state'] == 'pending':
        return
        color = 'bold-teal'
    else:
        print('Status: {}'.format(data['state']))
        color = 'black'

    repo = fmt_repo(data)
    repo_name = data['repository']['full_name']
    after_id = data['sha'][:12]
    befor_id = data['commit']['parents'][0]['sha'][:12]
    commit_id = colorize(after_id, 'bold', 'irc')
    desc = colorize(data['description'], color, 'irc')
    target_url = data['target_url'].split('?', 1)[0]
    change_url = 'https://github.com/{}/compare/{}...{}'.format(
        repo_name, befor_id, after_id)
    change = colorize('Change view:', 'teal', 'irc')
    build = colorize('Build details:', 'teal', 'irc')
    commit_msg = colorize(data['commit']['commit']['message'], 'green', 'irc')
    branch = colorize(data['branches'][0]['name'], 'bold-blue', 'irc')

    irc.schedule_message('{} {} on {}: {}'.format(repo, commit_id, branch,
                                                  desc))
    irc.schedule_message('{} {} {}'.format(change, commit_msg,
                                           short_gh_link(change_url)))
    irc.schedule_message('{} {}'.format(build, target_url))

    print('Status event')
示例#36
0
    def do_run(self):
        read_line = create_read_line_function(self.input_file, config.prompt)
        subs_compiler_command = get_compiler_command(self.options, self.exec_filename)

        while True:
            inp = read_line(self.input_num + 1)  # 1-indexed
            if inp is None:
                break

            col_inp, run_compiler = dot_commands.process(inp, self)

            if col_inp:
                if self.input_num < len(self.user_input):
                    self.user_input = self.user_input[: self.input_num]

                if incl_re.match(inp) is None:
                    typ = UserInput.COMMAND
                else:
                    typ = UserInput.INCLUDE

                self.user_input.append(UserInput(inp, typ))
                self.input_num += 1

            if run_compiler:
                self.compile_error = run_compile(subs_compiler_command, self)

                if self.compile_error is not None:
                    info = "Compile error - type .e to see it OR disregard if multi-line statement(s)\n"
                    print(colorize(info, "magenta"))
                    continue

                stdout_data, stderr_data = run_exec(self.exec_filename)

                if len(stdout_data) > self.output_chars_printed:
                    new_output = stdout_data[self.output_chars_printed :]
                    len_new_output = len(new_output)

                    print(new_output.decode("utf8"))

                    self.output_chars_printed += len_new_output
                    self.user_input[-1].output_chars = len_new_output

                if len(stderr_data) > self.error_chars_printed:
                    new_error = stderr_data[self.error_chars_printed :]
                    len_new_error = len(new_error)

                    print(new_error.decode("utf8"))

                    self.error_chars_printed += len_new_error
                    self.user_input[-1].error_chars = len_new_error

            print()  # ensure empty newline between commands
def getFrame():
    global tiff_frame
    global maxVal
    global minVal
    data = q.get(True, 500)
    if data is None:
        print('No Data')
    if camState == 'recording':
        startRec.hdf5_file.create_dataset(('image' + str(tiff_frame)),
                                          data=data)
        tiff_frame += 1
    minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(data)
    img = colors.colorize(data, colorMapType)
    return img
def to_avi(savepath, data, colormap, start, end):
    try:
        fourcc = cv2.VideoWriter_fourcc(*'XVID')
        fps = 8.7
        out = cv2.VideoWriter(savepath, fourcc, fps, (640, 480), True)
        print(data)
        for i in range(start, end):
            frame = data.frame(i, 640, 480)
            bgr = colors.colorize(frame, colormap)
            out.write(bgr)
        out.release()
        print('Saved ' + savepath)
    except:
        print('Error while saving ' + savepath)
    return
def to_tiffs(savepath, data, colormap, start, end):
    try:
        images = []
        for i in range(1, data.last_frame):
            frame = data.frame(i, 640, 480)
            bgr = colors.colorize(frame, colormap)
            # BGR2RGB conversion because of "Image.fromarray"
            rgb_image = cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB)
            images.append(Image.fromarray(rgb_image))

        images[0].save(savepath, compression='tiff_deflate',
                       save_all=True, append_images=images[1:])
        print('Saved ' + savepath)
    except:
        print('Error while saving ' + savepath)
    return
示例#40
0
    def run(self):

        self.init(database = True, write = False)

        if not (ctx.get_option('no_color') or ctx.config.get_option('uninstalled')):
            ctx.ui.info(colorize(_('Installed packages are shown in this color'), 'green'))
        
        if self.args:
            for arg in self.args:
                self.print_packages(arg)
        else:
            # print for all repos
            for repo in ctx.repodb.list():
                ctx.ui.info(_("Repository : %s\n") % repo)
                self.print_packages(repo)
        self.finalize()
示例#41
0
    def print_packages(self, repo):
        from pisi import packagedb
        from colors import colorize

        pkg_db = packagedb.get_db(repo)
        list = pkg_db.list_packages()
        installed_list = ctx.installdb.list_installed()
        list.sort()
        for p in list:
            package = pkg_db.get_package(p)
            if self.options.long:
                ctx.ui.info(unicode(package))
            else:
                pstr = p
                if p in installed_list:
                    pstr = colorize(p, "cyan")
                ctx.ui.info("%15s - %s " % (pstr, package.summary))
示例#42
0
    def print_packages(self, repo):
        from pisi import packagedb
        from colors import colorize

        pkg_db = packagedb.get_db(repo)
        list = pkg_db.list_packages()
        installed_list = ctx.installdb.list_installed()
        list.sort()
        for p in list:
            package = pkg_db.get_package(p)
            if self.options.long:
                ctx.ui.info(unicode(package))
            else:
                lenp = len(p)
                if p in installed_list:
                    p = colorize(p, 'cyan')
                p = p + ' ' * max(0, 15 - lenp)
                ctx.ui.info('%s - %s ' % (p, unicode(package.summary)))
示例#43
0
    def print_packages(self, repo):
        from pisi import packagedb

        list = ctx.packagedb.list_packages(repo)
        installed_list = ctx.installdb.list_installed()
        list.sort()
        for p in list:
            package = ctx.packagedb.get_package(p)
            if self.options.long:
                ctx.ui.info(unicode(package))
            else:
                lenp = len(p)
                if p in installed_list:
                    if ctx.config.get_option('uninstalled'):
                        continue
                    p = colorize(p, 'green')
                p = p + ' ' * max(0, 15 - lenp)
                ctx.ui.info('%s - %s ' % (p, unicode(package.summary)))
示例#44
0
文件: main.py 项目: bgizdov/pytodo
    def view(self, num=""):
        """show todo job"""
        if self.priority == 1:
            color = "red"
        elif self.priority == 2:
            color = "yellow"
        elif self.priority == 3:
            color = "green"
        elif self.priority == 4:
            color = "cyan"
        elif self.priority == 5:
            color = "blue"
        else:
            color = "white"

        if num != "":
            if self.todate != "":
                print colorize(color, "%d. %s | Due date: %s" % (num, self.todoJob, self.todate))
            else:
                print colorize(color, "%d. %s" % (num, self.todoJob))
        else:
            print colorize(color, "%s to %s" % (self.todoJob, self.todate))
示例#45
0
def fg_blue(string):
  return colorize(['FG_BLUE'], str(string))
示例#46
0
def black(string):
  return colorize(['FG_BLACK'], str(string))
示例#47
0
def bg_cyan(string):
  return colorize(['BG_CYAN'], str(string))
示例#48
0
def bg_white(string):
  return colorize(['BG_WHITE'], str(string))
示例#49
0
def bg_blue(string):
  return colorize(['BG_BLUE'], str(string))
示例#50
0
def bg_magenta(string):
  return colorize(['BG_MAGENTA'], str(string))
示例#51
0
def bg_green(string):
  return colorize(['BG_GREEN'], str(string))
示例#52
0
def bg_yellow(string):
  return colorize(['BG_YELLOW'], str(string))
示例#53
0
def fg_white(string):
  return colorize(['FG_WHITE'], str(string))
示例#54
0
def bg_red(string):
  return colorize(['BG_RED'], str(string))
示例#55
0
def fg_cyan(string):
  return colorize(['FG_CYAN'], str(string))
示例#56
0
def magenta(string):
  return colorize(['FG_MAGENTA'], str(string))
示例#57
0
def fg_yellow(string):
  return colorize(['FG_YELLOW'], str(string))
示例#58
0
def fg_green(string):
  return colorize(['FG_GREEN'], str(string))
示例#59
0
def fg_red(string):
  return colorize(['FG_RED'], str(string))