def main(): requests.packages.urllib3.disable_warnings() defaultConfig = { 'url': 'https://stream.watsonplatform.net/text-to-speech/api', 'user': '******', 'password': '******', 'voice': 'en-US_AllisonVoice', 'chunk': 2048 } home = os.path.expanduser("~") defaultConfigFile = home + '/.config-tts-watson.yml' parser = argparse.ArgumentParser( description='Text to speech using watson') parser.add_argument('-f', action='store', dest='configFile', default=defaultConfigFile, help='config file', required=False) parser.add_argument('text_to_transform', action='store', nargs='+') args = parser.parse_args() conf = anyconfig.container(defaultConfig) if not os.path.isfile(args.configFile): print "Config file '" + args.configFile + "' doesn't exist." print "Creating it ..." user = raw_input("Watson user: "******"Watson password: "******" ".join(args.text_to_transform))
def main(): defaultConfig = { 'url': 'https://gateway.watsonplatform.net/dialog/api', 'user': '******', 'password': '******', } home = os.path.expanduser("~") defaultConfigFile = home + '/.config-dialog-watson.yml' parser = argparse.ArgumentParser( description='Text to speech using watson') parser.add_argument('-f', action='store', dest='configFile', default=defaultConfigFile, help='config file', required=False) parser.add_argument('dialog_file', action='store', nargs=1) parser.add_argument('-n', '--name', dest='dialog_name', action='store', help='Dialog name', required=True) parser.add_argument('--clean', dest='clean', action='store_true') args = parser.parse_args() dialog_file = "".join(args.dialog_file) conf = anyconfig.container(defaultConfig) if not os.path.isfile(args.configFile): print "Config file '" + args.configFile + "' doesn't exist." print "Creating it ..." user = raw_input("Watson user: "******"Watson password: "******"".join(args.dialog_name), bconf.url, os.path.dirname(dialog_file) + "/dialog_id_file.txt") if args.clean: watsonClient.clean_dialogs() resp = watsonClient.start_dialog() print '' print bcolors.WARNING + "Watson: " + bcolors.OKBLUE + "\n".join(resp.response) + bcolors.ENDC while True: userResponse = raw_input(bcolors.WARNING + "You: " + bcolors.OKGREEN) resp = watsonClient.converse(userResponse) print bcolors.WARNING + "Watson: " + bcolors.OKBLUE + "\n".join(resp.response) + bcolors.ENDC if userResponse == "bye": break print "" print "Your profile:" for name, value in watsonClient.get_profile().get_data().iteritems(): print "\t" + name + ": " + value if __name__ == "__main__": main()
def load_site_ctxs(ctxs): """ Load context (conf) files from ``ctxs``. :param ctxs: List of context file[s], glob patterns of context files or dirs :: [str] """ conf = anyconfig.container() for ctxpath in ctxs: diff = load_site_ctx(ctxpath) if diff: conf.update(diff) else: logging.warn("No config loaded from: " + ctxpath) if not conf: raise EmptyConfigError("No config available from: " + ','.join(ctxs)) return conf
def main(): py3_input_conversion = lambda x: input( x) if sys.version_info.major >= 3 else raw_input(x) requests.packages.urllib3.disable_warnings() defaultConfig = { 'url': 'https://stream.watsonplatform.net/text-to-speech/api', 'user': '******', 'password': '******', 'voice': 'en-US_AllisonVoice', 'chunk': 2048 } home = os.path.expanduser("~") defaultConfigFile = home + '/.config-tts-watson.yml' parser = argparse.ArgumentParser(description='Text to speech using watson') parser.add_argument('-f', action='store', dest='configFile', default=defaultConfigFile, help='config file', required=False) parser.add_argument('text_to_transform', action='store', nargs='+') args = parser.parse_args() conf = anyconfig.container(defaultConfig) if not os.path.isfile(args.configFile): print("Config file '" + args.configFile + "' doesn't exist.") print("Creating it ...") user = py3_input_conversion("Watson user: "******"Watson password: "******" ".join(args.text_to_transform))
def main(): defaultConfig = { 'url': 'https://gateway.watsonplatform.net/dialog/api', 'user': '******', 'password': '******', } home = os.path.expanduser("~") defaultConfigFile = home + '/.config-dialog-watson.yml' parser = argparse.ArgumentParser(description='Text to speech using watson') parser.add_argument('-f', action='store', dest='configFile', default=defaultConfigFile, help='config file', required=False) parser.add_argument('dialog_file', action='store', nargs=1) parser.add_argument('-n', '--name', dest='dialog_name', action='store', help='Dialog name', required=True) parser.add_argument('--clean', dest='clean', action='store_true') args = parser.parse_args() dialog_file = "".join(args.dialog_file) conf = anyconfig.container(defaultConfig) if not os.path.isfile(args.configFile): print "Config file '" + args.configFile + "' doesn't exist." print "Creating it ..." user = raw_input("Watson user: "******"Watson password: "******"".join(args.dialog_name), bconf.url, os.path.dirname(dialog_file) + "/dialog_id_file.txt") if args.clean: watsonClient.clean_dialogs() resp = watsonClient.start_dialog() print '' print bcolors.WARNING + "Watson: " + bcolors.OKBLUE + "\n".join( resp.response) + bcolors.ENDC while True: userResponse = raw_input(bcolors.WARNING + "You: " + bcolors.OKGREEN) resp = watsonClient.converse(userResponse) print bcolors.WARNING + "Watson: " + bcolors.OKBLUE + "\n".join( resp.response) + bcolors.ENDC if userResponse == "bye": break print "" print "Your profile:" for name, value in watsonClient.get_profile().get_data().iteritems(): print "\t" + name + ": " + value if __name__ == "__main__": main()
from __future__ import print_function from logging import DEBUG, INFO import rpmkit.globals as G import rpmkit.rpmutils as RR import rpmkit.utils as RU import rpmkit.extras.rk_dnf as RED import anyconfig import bunch import logging import optparse import os.path import sys _DATA_0 = anyconfig.container() def load_profiles(profilesdir, data=_DATA_0, merge_strategy=anyconfig.MS_DICTS_AND_LISTS): """ :param profiles: """ ps = os.path.join(profilesdir, "*.yml") diff = anyconfig.load(ps, merge=merge_strategy) if diff: if data: data.update(diff) else:
from logging import DEBUG, INFO import rpmkit.globals as G import rpmkit.rpmutils as RR import rpmkit.utils as RU import rpmkit.extras.rk_dnf as RED import anyconfig import bunch import logging import optparse import os.path import sys _DATA_0 = anyconfig.container() def load_profiles(profilesdir, data=_DATA_0, merge_strategy=anyconfig.MS_DICTS_AND_LISTS): """ :param profiles: """ ps = os.path.join(profilesdir, "*.yml") diff = anyconfig.load(ps, merge=merge_strategy) if diff: if data: data.update(diff) else: data = diff
# If the log file is specified on the command line then override the default args = parser.parse_args() if args.log: LOG_FILENAME = args.log logging.basicConfig(level=args.loglevel, filename=LOG_FILENAME, format='%(asctime)s:%(levelname)s:%(message)s', datefmt='%m/%d/%Y %H:%M:%S') else: # log to console logging.basicConfig(level=args.loglevel, format='%(asctime)s:%(levelname)s:%(message)s', datefmt='%m/%d/%Y %H:%M:%S') proxy = Proxy(args.serial) cmdQ = queue.Queue() conf_file = "rf24_proxy.conf" if not os.path.isfile(conf_file): conf_file = "/etc/" + conf_file config = anyconfig.load(conf_file, "properties") if os.path.isfile(conf_file) else anyconfig.container() class MQ(threading.Thread): """ Class for communicating with MQTT. Publishing and also subscribing to particular topics """ client = mqtt.Client() queue = queue.Queue() on_message_callback = None def __init__(self): threading.Thread.__init__(self) # self.client.on_connect = self.on_connect self.client.on_message = self.on_message
radio.setPALevel(NRF24.PA_LOW) radio.setAutoAck(1) radio.openWritingPipe(pipes[0]) radio.openReadingPipe(1, pipes[1]) radio.startListening() radio.stopListening() radio.printDetails() radio.startListening() cmdQ = Queue.Queue() conf_file = "rf24_proxy.conf" if not os.path.isfile(conf_file): conf_file = "/etc/" + conf_file config = anyconfig.load(conf_file, "properties") if os.path.isfile(conf_file) else anyconfig.container() class MQ(threading.Thread): """ Class for communicating with MQTT. Publishing and also subscribing to particular topics """ client = mqtt.Client() queue = Queue.Queue() on_message_callback = None def __init__(self): threading.Thread.__init__(self) # self.client.on_connect = self.on_connect self.client.on_message = self.on_message