which describe the specification, are also used here. Also, docstrings may contain specification text copied directly from the Roomba SCI Spec Manual and the Turtlebot Open Interface specification. Since SCI is a subset of OI, PyRobot first defines the Roomba's functionality in the Roomba class and then extends that with the Turtlebot's additional functionality in the Turtlebot class. In addition, since OI is built on SCI the SerialCommandInterface class is also used for OI. """ __author__ = "[email protected] (Damon Kohler)" import logging from lagerlogger import LagerLogger logging = LagerLogger() logging.console(LagerLogger.DEBUG) import math import serial import struct import time import threading import traceback import rospy ROOMBA_OPCODES = dict( start=128, reset=7, baud=129, control=130, safe=131, full=132,
import subprocess as sp if __name__ == '__main__' and __package__ is None: from os import path, sys sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) try: from logging import console from flac import flac, flacdecode from config import ipath except ImportError: from .logging import console from .flac import flac, flacdecode from .config import ipath log = console(stderr=True) class lameMp3(object): def __init__(self, opts): self.opts = opts def generate_lame_meta(self, metastring): tagstring = [] def update_tagstring(items): tagstring.extend([items[0], "%s" % items[1]]) # Capitalise the Genre, as per lame requirements if "GENRE" in metastring: metastring['GENRE'] = metastring['GENRE'].capitalize()
def main(): global log options, args = build_parser() # update the opts dictionary with new values opts.update(eval(options.__str__())) # convert the formats in the args to valid formats for lame and oggenc opts['oggencopts'] = ' --' + ' --'.join(opts['oggencopts'].split(':')) opts['opusencopts'] = ' --' + ' --'.join(opts['opusencopts'].split(':')) # lame is not consistent, sometimes using long opts,sometimes not # so we need to specify on command line with dashes whether it is a long op or # short opts['lameopts'] = ' -' + ' -'.join(opts['lameopts'].split(':')) # ffmpeg uses colons as delimiters, just like flac2all (of course), so we had to # switch to commas for this one opts['ffmpegopts'] = opts['ffmpegopts'].split(',') opts['ffmpegopts'] = list( flatten([x.split(' ') for x in opts['ffmpegopts']])) try: opts['mode'] = args[0] except (IndexError): # if no arguments specified print("No mode specified! Run with '-h' for help") sys.exit(1) # quit the program with non-zero status try: opts['dirpath'] = os.path.abspath(args[1]) except (IndexError): print("No directory specified! Run with '-h' for help") sys.exit(2) # quit the program with non-zero status # end command line checking # Commence main logic if options.curses is True: log = cconsole() # switch to cconsole, if specified as option else: log = console(stderr=True) # Check if we have the special mode "all", which really brings flac2all into # perspective. We convert to every single format supported. This is mainly added for # testing reasons. if opts['mode'] == "all": opts['mode'] = ','.join( [x[0] for x in modetable if not x[0].startswith("_")]) # In this version, we can convert multiple format at once, so for e.g. # mode = mp3,vorbis will create both in parallel for mode in opts['mode'].split(','): if mode != "": # When copying, we don't want a _copy dir, but one representing # the mode being copied to, so we check and update mode here if "copymode" in opts: mode = opts['copymode'] # As the copy folder is created in the shell module, we # do not have to do anything else here continue try: os.mkdir(os.path.join(opts['outdir'], mode)) except OSError as e: if e.errno == 17: log.info("Folder %s already exists, reusing..." % mode) elif e.errno == 2: log.info("Parent path %s does not exist! quitting..." % (opts['outdir'])) else: # everything else, raise error raise e # Magic goes here :) if opts['master_enable']: clustered_encode() else: clustered_encode(localworkers=True) if options.curses is True: log.__del__( ) # If we are using the curses interface, clean up properly at the end.