How to use the rpyc.Service function in rpyc

To help you get started, we’ve selected a few rpyc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moloch-- / The-Planetary-Assault-System / WeaponSystem / WeaponSystem.py View on Github external
self.mutex.acquire()
        try:
            results = method(self, *args, **kwargs)
        except Exception as error:
            method_exception = error
        finally:
            # Always release mutex, even if the method raised 
            # an exception
            self.mutex.release()
            if method_exception is not None:
                raise Exception(method_exception)
        return results
    return wrapper


class WeaponSystem(rpyc.Service):
    '''
    RPC Services: This is the code that does the actual password cracking
    and returns the results to orbital control.  Currently only supports
    cracking using rainbow tables (RCrackPy)
    '''

    is_initialized = False
    mutex = Lock()
    is_busy = False
    job_id = None

    def initialize(self):
        ''' Initializes variables, this should only be called once '''
        logging.info("Weapon system initializing ...")
        self.plugin_manager = PluginManager()
        self.plugin_manager.setPluginPlaces(["plugins/"])
github hansjhoffman / crispy-fortnight / crispy / network / service.py View on Github external
import logging 
import rpyc.core.service
import sys

logger = logging.getLogger(__name__)

from .. lib.fprint import *

class CrispyService(rpyc.Service):
    def __init__(self, *args, **kwargs):
        super(CrispyService, self).__init__(*args, **kwargs)
        self.srv = global_srv

    def on_connect(self):
        logger.debug("on_connect() was called")
       
        try:
            self._conn._config.update(dict(
                allow_safe_attrs = True,
                allow_public_attrs = False,
                allow_pickle = False,
                allow_getattr = True,
                allow_delattr = False,
                allow_setattr = False,
                import_custom_exceptions = False,
github tomerfiliba / rpyc / demos / time / time_service.py View on Github external
import time
from rpyc import Service


class TimeService(Service):
    def exposed_get_utc(self):
        return time.time()

    def exposed_get_time(self):
        return time.ctime()
github sanketplus / PyDFS / pydfs / minion.py View on Github external
import rpyc
import uuid
import os

from rpyc.utils.server import ThreadedServer

DATA_DIR="/tmp/minion/"

class MinionService(rpyc.Service):
  class exposed_Minion():
    blocks = {}

    def exposed_put(self,block_uuid,data,minions):
      with open(DATA_DIR+str(block_uuid),'w') as f:
        f.write(data)
      if len(minions)>0:
        self.forward(block_uuid,data,minions)


    def exposed_get(self,block_uuid):
      block_addr=DATA_DIR+str(block_uuid)
      if not os.path.isfile(block_addr):
        return None
      with open(block_addr) as f:
        return f.read()
github darosior / c-simple / c-simple / csimple / lightningservice.py View on Github external
from rpyc import MasterService, Service
from lightning import LightningRpc
import time
import os

class LightningService(Service):
    """
    The service class, used by RPyC to expose methods.
    
    We are intentionnally not exposing all the methods provided by LightningRpc since the wallet doesn't require them.
    This may change in the future if we want to provide a remote access.
    """
    def on_connect(self, conn):
        """
        Executed by RPyC when a connection is set up.

        :param conn: The connection. Kind of a socket
        """
        self.l = LightningRpc(self.get_lightning_daemon())
        
    def on_disconnect(self, conn):
        """
github Ulm-IQO / qudi / core / remote.py View on Github external
def makeRemoteService(self):
        """ A function that returns a class containing a module list hat can be manipulated from the host.
        """
        class RemoteModuleService(rpyc.Service):
            """ An RPyC service that has a module list.
            """
            modules = self.sharedModules
            _manager = self.manager

            @staticmethod
            def get_service_name():
                return 'RemoteModule'

            def on_connect(self):
                """ code that runs when a connection is created
                    (to init the service, if needed)
                """
                logger.info('Client connected!')

            def on_disconnect(self):
github kizniche / Mycodo / 3.0 / cgi-bin / mycodo.py View on Github external
variableValue = None
ClientQue = '0'
ClientVar1 = None
Terminate = False
TAlive = [1] * 5
HAlive = [1] * 5
Temp_PID_Down = 0
Temp_PID_Up = 0
Hum_PID_Down = 0
Hum_PID_Up = 0
Temp_PID_number = None
Hum_PID_number = None
Terminate_final = 1

# Threaded server that receives commands from mycodo-client.py
class ComServer(rpyc.Service):
    def exposed_ChangeRelay(self, relay, state):
        if (state == 1):
            logging.info("[Client command] Changing Relay %s to HIGH", relay)
            relay_onoff(int(relay), 1)
        elif (state == 0):
            logging.info("[Client command] Changing Relay %s to LOW", relay)
            relay_onoff(int(relay), 0)
        else:
            logging.info("[Client command] Turning Relay %s On for %s seconds", relay, state)
            rod = threading.Thread(target = relay_on_duration, 
                args = (int(relay), int(state), 0,))
            rod.start()
        return 1
    def exposed_ChangeTimer(self, timernumber, timerstate, timerrelay,
            timerdurationon, timerdurationoff):
        global ClientQue
github Luxoft / Twister / client / executionprocess / ExecutionProcess.py View on Github external
STATUS_ABORTED = 5
STATUS_NOT_EXEC = 6
STATUS_TIMEOUT = 7
STATUS_INVALID = 8
STATUS_WAITING = 9

TEST_STATUS = {'pending':STATUS_PENDING, 'working':STATUS_WORKING,\
'pass':STATUS_PASS, 'fail':STATUS_FAIL, 'skipped':STATUS_SKIPPED,\
'aborted':STATUS_ABORTED, 'not executed':STATUS_NOT_EXEC,\
'timeout':STATUS_TIMEOUT, 'invalid':STATUS_INVALID, 'waiting':STATUS_WAITING}

REVERSED_STATUS = dict((v, k) for k, v in TEST_STATUS.iteritems())

# ------------------------------------------------------------------------------

class EpService(rpyc.Service):
    """
    Dummy service.
    """
    def exposed_hello(self, param=None):
        """
        For testing connection.
        """
        return True

    def exposed_start_ep(self, *arg, **kw):
        """
        Fake function.
        """
        return True

    def exposed_stop_ep(self, *arg, **kw):
github snario / zknifty / services / proof / main.py View on Github external
import rpyc
from prover import generate_transfer_proof


class ProofService(rpyc.Service):

    def on_connect(self, conn):
        # code that runs when a connection is created
        # (to init the service, if needed)
        print('Connected to proof service!')
        pass

    def on_disconnect(self, conn):
        # code that runs after the connection has already closed
        # (to finalize the service, if needed)
        print('Disconnected from proof service!')
        pass

    def exposed_proof(self, txs):
        print('Received request for zksnark proof.')
        root, proof = generate_transfer_proof(txs)
github Kkevsterrr / backdoorme / backdoors / shell / __pupy / pupy / pupylib / PupyService.py View on Github external
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
# 
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
# 
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
# --------------------------------------------------------------

import rpyc.core.service
import rpyc
import threading
import sys
import ssl

class PupyService(rpyc.Service):
	def __init__(self, *args, **kwargs):
		super(PupyService, self).__init__(*args, **kwargs)
		self.pupy_srv=glob_pupyServer
	def on_connect(self):
		# code that runs when a connection is created
		# (to init the serivce, if needed)
		self._conn._config.update(dict(
			allow_safe_attrs = True,
			allow_public_attrs = False,
			allow_pickle = False,
			allow_getattr = True,
			allow_setattr = False,
			allow_delattr = False,
			import_custom_exceptions = False,
			instantiate_custom_exceptions = False,
			instantiate_oldstyle_exceptions = False,