def bitcoinwand_call(address, message, url):
    bitcoinwand_args = [get_python_exe(), os.path.join(PROGRAM_DIR, 'bitcoinwand.py'), address, message, url]

    print('\nCALL: %s' % ' '.join(bitcoinwand_args))
    bitcoinwand = Popen(format_args(bitcoinwand_args), stdout=PIPE, stderr=PIPE, shell=True)
    output, error = bitcoinwand.communicate()
    stripped_output = output.strip()
    print('RESPONSE: %s\n' % stripped_output)

    stripped_error = error.strip()
    if len(stripped_error):
        print('\n------------------BEGIN OF BITCOINWAND ERROR------------------', file=sys.stderr)
        print(stripped_error, file=sys.stderr)
        print('\nCALL: %s' % ' '.join(bitcoinwand_args), file=sys.stderr)
        print('------------------END OF BITCOINWAND ERROR------------------\n', file=sys.stderr)

    if len(stripped_output):
        bitcoinwand_response = simplejson.loads(stripped_output)
        return bitcoinwand_response
    def run(self):
        process_id = multiprocessing.current_process().name
        PROCESS_LOG.info('%s | Spawned new process to run command: %s' %
                         (process_id, self.command))
        PROCESS_LOG.info('%s | Process starting...' % process_id)

        command_process = Popen(format_args(self.command),
                                stdout=PIPE,
                                stderr=PIPE,
                                shell=True,
                                universal_newlines=True)

        for stdout_line in iter(command_process.stdout.readline, ""):
            PROCESS_LOG.info('%s | %s' % (process_id, stdout_line.strip()))

        for stdout_line in iter(command_process.stderr.readline, ""):
            PROCESS_LOG.error('%s | %s' % (process_id, stdout_line.strip()))

        PROCESS_LOG.info('%s | Process finished' % process_id)
def spellbook_call(*args):
    args = [str(arg) for arg in args]
    spellbook_args = [get_python_exe(), os.path.join(PROGRAM_DIR, 'spellbook.py')]
    spellbook_args.extend(args)

    print('\nCALL: %s' % ' '.join(spellbook_args))
    spellbook = Popen(format_args(spellbook_args), stdout=PIPE, stderr=PIPE, shell=True)
    output, error = spellbook.communicate()
    stripped_output = output.strip().decode()
    print('RESPONSE: %s\n' % stripped_output)

    stripped_error = error.strip()
    if len(stripped_error):
        print('\n------------------BEGIN OF SPELLBOOK ERROR------------------', file=sys.stderr)
        print(stripped_error, file=sys.stderr)
        print('\nCALL: %s' % ' '.join(spellbook_args), file=sys.stderr)
        print('------------------END OF SPELLBOOK ERROR------------------\n', file=sys.stderr)

    if len(stripped_output):
        spellbook_response = simplejson.loads(stripped_output)
        return spellbook_response