def restcall(**kwargs): print colors.faint('=' * 120) r = request(**kwargs) print colors.green(r.request.method + ' ' + r.request.url) print_headers(r.request.headers) print if 'data' in kwargs: # print colors.faint('Form data:') # print_headers(kwargs['data']) print kwargs['data'] elif 'json' in kwargs: print_json(kwargs['json']) else: print r.request.body print print colors.faint('({:.3f} seconds)'.format(r.elapsed.total_seconds())) print if r.status_code < 300: color = colors.green elif r.status_code < 400: color = colors.yellow else: color = colors.red print color('{} {}'.format(r.status_code, r.reason)) print_headers(r.headers, format_names=True) print try: print_json(r.json()) except: print r.text return r
def get_todo_str(self, todo, date=False, completed_faint=False, notes=False): """Get a nicely formatted and colored string describing a task.""" todo_str = "%-*s" % (40, todo['text']) # If dates should be printed, add the planning and drop-dead dates if date: plan_date = "" plan_date_obj = todo.get_planning_date() if plan_date_obj: plan_date = pretty.date(plan_date_obj) due = "" if 'date' in todo.keys() and todo['date']: dt_obj = dateutil.parser.parse(todo['date']) due = pretty.date(dt_obj) todo_str += " Plan: %-*s Due:%-*s" % (15, plan_date, 15, due) # Underline the string if the task is urgent tags = [tag for tag in todo['tags'].keys() if todo['tags'][tag]] if 'urgent' in [self.user['tag_dict'][tag] for tag in tags]: todo_str = colors.underline(todo_str) # Make the string faint if it has been completed if completed_faint: if 'completed' in todo.keys() and todo['completed']: todo_str = colors.faint(todo_str) # Format the notes as an indented block of text if notes: wrapper = textwrap.TextWrapper(initial_indent=" "*4, subsequent_indent=""*4) todo_str += "\n" + wrapper.fill(todo['notes']) return todo_str
def debug(message='', *args): log(faint('DEBUG: ' + message), *args)
def __enter__(self): sys.stdout.write(faint(self.message + ' ... ')) sys.stdout.flush()
def recv(self, quiet=False): data = self.serial.read(self.serial.inWaiting()) clearData = data.decode('utf8').strip() if clearData and self.verbose and not quiet: logPrint(colors.faint(colors.red(clearData))) return data