Пример #1
0
def run():
    # server = ServerProxy('172.16.101.209')
    # rstr = server.get('username', url)
    address = input("server address : ")
    proxy = ServerProxy(address, 8000, allow_none=True)
    multicall = MultiCall(proxy)
    multicall.music()
Пример #2
0
    def call(self):
        """Execute added multicall calls

        @return: the results (post-processed), in the order they were added
        @rtype: tuple
        """
        m = MultiCall(self.rt_obj._get_conn())
        for call in self.calls:
            method, args = call
            rpc_call = getattr(method, "rpc_call")
            getattr(m, rpc_call)(*args)

        results = m()
        results = tuple(results)
        results_processed = []

        for r, c in zip(results, self.calls):
            method = c[0]  # Method instance
            result = process_result(method, r)
            results_processed.append(result)
            # assign result to class_obj
            exists = hasattr(self.class_obj, method.varname)
            if not exists or not inspect.ismethod(
                    getattr(self.class_obj, method.varname)):
                setattr(self.class_obj, method.varname, result)

        return (tuple(results_processed))
Пример #3
0
    def migrate_tickets(self):
        '''
        Executes the trac query and calls the functions to initiate and terminate 
        the GH migration
        '''
        for repo_name, query in GITHUB_REPO_TRAC_QUERY_MAP.items():
            print(
                "Loading information from Trac query '{}' and migrating it to repo '{}'..."
                .format(query, repo_name))

            get_all_tickets = MultiCall(self.trac)
            for ticket in self.trac.ticket.query(query):
                get_all_tickets.ticket.get(ticket)

            # Take the memory hit so we can rewrite ticket references:
            all_trac_tickets = list(get_all_tickets())
            print("Tickets loaded {}.".format(len(all_trac_tickets)))

            print("-" * 80)
            print("Creating GitHub tickets now...")
            self.creat_incomplete_github_issues(all_trac_tickets, repo_name)

            print("-" * 80)
            print("Migrating descriptions and comments...")
            self.complete_github_issues(all_trac_tickets, repo_name)
Пример #4
0
    def _reconstruct_remote_tree(self, remote_fs_meta_data):
        dirs_to_create = [
            dir for dir in self.fs_tree
            if dir not in remote_fs_meta_data.fs_tree
        ]
        files_to_create = self.get_all_files(
        ) - remote_fs_meta_data.get_all_files()
        multicall = MultiCall(self.peer)

        for dir in dirs_to_create:
            multicall.mkdir(dir)
        for file, size in files_to_create:
            multicall.mkfile(file, size)

        pc = percent_gen(len(dirs_to_create) + len(files_to_create))
        for _ in multicall():
            ui_message("Initial Synch: Reconstruction of tree...  {}%".format(
                next(pc)))
Пример #5
0
    server.register_instance(MyFuncs())
    # Run the server's main loop
    server.serve_forever()

# create client

from xmlrpc.client import ServerProxy, Error, MultiCall

server = ServerProxy("http://localhost:8000")

# try:
#     print(server.currentTime.getCurrentTime())
# except Error as v:
#     print("ERROR", v)

multi = MultiCall(server)
multi.pow(2, 9)
multi.add(1, 2)
# # Print list of available methods
# print(s.system.listMethods())
try:
    for response in multi():
        print(response)
except Error as v:
    print("ERROR", v)
"""
DocXMLRPCServer对象
本DocXMLRPCServer类源自SimpleXMLRPCServer 并提供创建自我记录的手段,独立的XML-RPC服务器。HTTP POST请求作为XML-RPC方法调用处理。
通过生成pydoc样式的HTML文档来处理HTTP GET请求。这允许服务器提供其自己的基于Web的文档。

DocXMLRPCServer.set_server_title(server_title )
Пример #6
0
 def get_multi(self):
     """
     :returns:: multicall XMLRPC proxy for communicating with master, ``xmlrpc.client.MultiCall``
     """
     return MultiCall(self.get())
Пример #7
0
    def _workvalues(self, io_dicts=None, writeout=False):
        u"""Alle Werte der Inputs und Outputs abrufen.

        @param io_dicts Arbeit nur für dieses Dict()
        @param writeout Änderungen auf RevPi schreiben
        @return None

        """
        # Abfragelisten vorbereiten
        if io_dicts is None:
            io_dicts = [self.dict_inps, self.dict_outs]

        # Werte abrufen
        with self.lk:
            try:
                ba_values = bytearray(self.cli.ps_values().data)
                self.err_workvalues = 0
            except Exception:
                if self.autorw.get():
                    self.err_workvalues += 1
                else:
                    self.err_workvalues = self.max_errors

                if self.err_workvalues >= self.max_errors:
                    # Fenster zerstören bei zu vielen Fehlern
                    self.hideallwindows()
                    if self.autorw.get():
                        self.autorw.set(False)
                        self.toggleauto()
                    self.dowrite.set(False)
                    self.pack_forget()

                    tkmsg.showerror(
                        _("Error"),
                        _("To many errors while reading IO data. "
                            "Can not show the Watch-Mode."),
                        parent=self.master
                    )

                return None

        # Multicall zum Schreiben vorbereiten
        if writeout:
            xmlmc = MultiCall(self.cli)

        for dev in self.dict_devices:
            # io = [name,blen,baddr,bmk,bitaddr,(tkinter_var),border,signed]

            # IO Typ verarbeiten
            for iotype in io_dicts:
                # ios verarbeiten
                for io in iotype[dev]:

                    # Gesperrte Variable überspringen
                    if io[5] == self.__lockedvar:
                        continue

                    # Bytes umwandeln
                    int_byte = int.from_bytes(
                        ba_values[io[2]:io[2] + io[1]],
                        byteorder="little" if len(io) < 7 else io[6],
                        signed=False if len(io) < 8 else io[7],
                    )
                    if io[4] >= 0:
                        # Bit-IO
                        new_val = bool(int_byte & 1 << io[4])
                        if writeout and new_val != io[5].get():
                            xmlmc.ps_setvalue(dev, io[0], io[5].get())
                        else:
                            io[5].set(new_val)
                    else:
                        # Byte-IO
                        if writeout and int_byte != io[5].get():
                            xmlmc.ps_setvalue(dev, io[0], io[5].get())
                        else:
                            io[5].set(int_byte)

        # Werte per Multicall schreiben
        if writeout:
            with self.lk:
                self.validatereturn(xmlmc())
Пример #8
0
    size = server.d.get_size_bytes(h)
    total_size += size
    base_path = server.d.get_base_path(h)
    print(h[:5], name, to_mb(size), "MB")

    for n in range(server.d.get_size_files(h)):
        name = server.f.get_path(h, n)
        size = server.f.get_size_bytes(h, n)
        chunks = server.f.get_completed_chunks(h, n)
        total_chunks = server.f.get_size_chunks(h, n)
        percentage = int(chunks / total_chunks * 100)

        if size > 1024 * 1024 * 1024:
            server.f.set_priority(h, n, 0)
            full_path = os.path.join(base_path, name)
            if os.path.exists(full_path):
                os.unlink(full_path)
        else:
            downloading_size += size

        priority = server.f.get_priority(h, n)
        print(f"\t[{priority}] {name} - {to_mb(size)}MB - {percentage}%")

mc = MultiCall(server)
mc.get_up_rate()
mc.get_down_rate()
up_rate, down_rate = mc()

print(f"total size: {to_mb(total_size)}MB")
print(f"downloading size: {to_mb(downloading_size)}MB")
Пример #9
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from xmlrpc.client import ServerProxy, MultiCall

cli = ServerProxy("http://localhost:1337")

mc = MultiCall(cli)
for i in range(10):
    mc.fak(i)
    mc.quad(i)

for ergebnis in mc():
    print(ergebnis)
Пример #10
0
    def _work_values(self, refresh=False, write_out=False, process_image=None):
        """
        Read input and output values.

        :param refresh: Refresh unchanged ios from process image
        :param write_out: Write changed outputs to process image
        :param process_image: Use this <class 'Binary'> for work and do not fetch
        """
        if process_image is not None:
            ba_values = process_image
        else:
            try:
                ba_values = helper.cm.call_remote_function("ps_values", raise_exception=True)
            except Fault:
                pi.logger.warning("Detected piCtory reset.")
                self._driver_reset_detected()
                return
            except Exception as e:
                pi.logger.error(e)
                ba_values = Binary()

        # From now on use bytes instead of Binary
        ba_values = bytearray(ba_values.data)

        if not ba_values:
            if self.cbx_refresh.isChecked():
                self.err_workvalues += 1
            else:
                # Raise error on button press
                self.err_workvalues = self.max_errors

            if self.err_workvalues >= self.max_errors:
                for win in self.dict_windows.values():  # type: DebugIos
                    win.stat_bar.setStyleSheet("background-color: red;")
                    win.stat_bar.showMessage(self.tr(
                        "Error while getting values from Revolution Pi."
                    ), 5000)

            return

        if self.err_workvalues > 0:
            self.err_workvalues = 0
            for win in self.dict_windows.values():  # type: DebugIos
                win.stat_bar.setStyleSheet("")

        # Use multicall to set all changed values
        if write_out and helper.cm.connected:
            cli = helper.cm.get_cli()
            xmlmc = MultiCall(cli)
        else:
            xmlmc = []

        for io_type in self.dict_ios:
            for position in self.dict_ios[io_type]:
                if position not in self.dict_windows:
                    continue

                win = self.dict_windows[position]
                for io in self.dict_ios[io_type][position]:  # type: list
                    # ['name', bitlength, byte_address, 'bmk', bitaddress, 'byteorder', signed]
                    value_procimg = bytes(ba_values[io[2]:io[2] + io[1]])
                    if io[4] >= 0:
                        # Bit-IO
                        value_procimg = bool(
                            int.from_bytes(value_procimg, byteorder=io[5], signed=io[6]) & 1 << io[4]
                        )

                    if (refresh or write_out) and io_type == "out":
                        widget_value, last_value = win.get_value(io[0])
                        if widget_value != last_value:
                            # User changed value

                            if not write_out:
                                # Do not write output after change to save this state
                                continue

                            value_procimg = widget_value
                            if type(xmlmc) == MultiCall:
                                xmlmc.ps_setvalue(position, io[0], widget_value)
                            else:
                                # Simulate multicall an collect result to list
                                xmlmc.append(
                                    helper.cm.call_remote_function("ps_setvalue", position, io[0], widget_value)
                                )

                    win.set_value(io[0], value_procimg)

                if self.cbx_refresh.isChecked():
                    win.stat_bar.showMessage(self.tr("Auto update values..."), 1000)
                else:
                    win.stat_bar.showMessage(self.tr("Values updated..."), 2000)

                if self.driver_reset_detected:
                    # Show values, which we can recover to empty process image
                    win.reset_change_value_colors()

        self.driver_reset_detected = False

        # Set values by multi call
        if write_out:
            if isinstance(xmlmc, list):
                self._validate_multicall(xmlmc)
            else:
                self._validate_multicall(xmlmc())
Пример #11
0
from xmlrpc.client import ServerProxy, MultiCall, Error

server = ServerProxy("http://localhost:8000")
print(server)
print(server.multiply(10, 5))
multi = MultiCall(server)
multi.pow(2, 9)
multi.add(5, 1)
multi.add(24, 11)
multi.multiply(2, 5)
try:
    for response in multi():
        print(response)
except Error as v:
    var = "ERROR", v
    print(var)