Example #1
0
 def __init__(self):
     proc = Popen(["node", "./node/coz"],
                  stdin=PIPE,
                  stdout=PIPE,
                  universal_newlines=True)
     self.proc = proc
     self.rpc = jsonrpyc.RPC(stdout=proc.stdin, stdin=proc.stdout)
     # First message must have id>0 or it is treated as notification. Node json-rpc-server-stream bug?
     self.rpc._i = 0
Example #2
0
File: rpc.py Project: riga/jsonrpyc
    def __init__(self, *args, **kwargs):
        super(RPCTestCase, self).__init__(*args, **kwargs)

        cwd = os.path.dirname(os.path.abspath(__file__))
        self.p = Popen(["python", "server/simple.py", "start"],
                       stdin=PIPE,
                       stdout=PIPE,
                       cwd=cwd)

        self.rpc = jsonrpyc.RPC(stdout=self.p.stdin, stdin=self.p.stdout)
Example #3
0
def start():
    import jsonrpyc
    jsonrpyc.RPC(MyClass())
    if not port:
        return
    try:
        rpc.call('onPortRegistered', [port.name,port.is_input,
                 port.shortname, port.is_audio, registered])
    except Exception:
        print(traceback.format_exc())
        raise

def onPortConnect(a, b, c):
    rpc.call("onPortConnected", [a.is_output, a.name, b.name, c])


jackclient.worker.set_port_connect_callback(onPortConnect)
jackclient.worker.set_port_registration_callback(onPortRegistered, only_available=False)
rpc = jsonrpyc.RPC(jackclient)
#jackclient.activate()

import os
import sys

ppid = os.getppid()


#https://stackoverflow.com/questions/568271/how-to-check-if-there-exists-a-process-with-a-given-pid-in-python
def check_pid(pid):        
    """ Check For the existence of a unix pid. """
    try:
        os.kill(pid, 0)
    except OSError:
        return False
Example #5
0
# -*- coding: utf-8 -*-

import os
import sys

sys.path.append(os.path.dirname(os.getcwd()))


class MyClass(object):
    def one(self):
        return 1

    def twice(self, n):
        return n * 2

    def arglen(self, *args, **kwargs):
        return len(args) + len(kwargs)


if __name__ == "__main__":
    import jsonrpyc

    rpc = jsonrpyc.RPC(MyClass())
Example #6
0
"""
Kicks things off via

python -m nnreddit

"""

import os
import sys
import jsonrpyc
import argparse

from .authenticated_reddit import AuthenticatedReddit

parser = argparse.ArgumentParser()
parser.add_argument("--log", help="log filename")
parser.add_argument("--localhost", help="ip or hostname of localhost", default='127.0.0.1')
args = parser.parse_args()

stdin = sys.stdin
stdout = sys.stdout
if __name__ != "__main__":
    sys.stdout = sys.stderr = open(os.devnull, "w")

jsonrpyc.RPC(target=AuthenticatedReddit(check_for_updates=False,
                                        log_prefix=args.log,
                                        localhost=args.localhost),
             stdin=stdin, stdout=stdout)
Example #7
0
                self.weakrefs[str(value)] = value

            prop = prop.replace("_", "-")

            prop = prop.split(":")
            if len(prop) > 1:
                childIndex = int(prop[0])
                target = element.get_child_by_index(childIndex)
                target.set_property(prop[1], value)
                self.weakrefs[str(target) + "fromgetter"] = target
            else:
                element.set_property(prop[0], value)

    def isActive(self):
        with self.lock:
            if self.pipeline.get_state(1000_000_000)[1] == Gst.State.PAUSED:
                return True
            if self.pipeline.get_state(1000_000_000)[1] == Gst.State.PLAYING:
                return True


gstp = GStreamerPipeline()
rpc[0] = jsonrpyc.RPC(target=gstp)

# def print(*a):
#     rpc[0]("print", [str(a)])

while not rpc[0].threadStopped:
    time.sleep(10)
    if not check_pid(ppid):
        sys.exit()
Example #8
0
stdin = sys.stdin
stdout = sys.stdout
if __name__ != "__main__":
    sys.stdout = sys.stderr = open(os.devnull, "w")

logdir = os.path.join(os.path.dirname(__file__), 'log')
try:
    os.makedirs(logdir)
except OSError:
    if not os.path.isdir(logdir):
        raise

super_secret = os.path.join(os.path.dirname(TOKEN),
                            'super-secret-refresh-token')
kwargs = {
    'token_file':
    args.token_file if args.token_file else
    (super_secret if os.path.exists(super_secret) else TOKEN),
    'history_file':
    mkstemp(dir='/var/tmp')[1],
}
jsonrpyc.RPC(target=AuthenticatedReddit(log_prefix=os.path.join(
    logdir, 'test_py.'),
                                        decode_html_entities=False,
                                        disable_update_check=True,
                                        check_for_updates=False,
                                        **kwargs),
             stdin=stdin,
             stdout=stdout)