Пример #1
0
def main():
    conn = Server('http://localhost:12000')
    parameters = sys.argv[1:]
    function = parameters[0]
    number1 = parameters[1]
    number2 = parameters[2]
    print("calling: " + function + '(' + number1 + ', ' + number2 + ')')
    print(conn.execute(function, number1, number2))
Пример #2
0
class Client(object):
    def __init__(self, host, port):
        super(Client, self).__init__()
        self.log = logging.getLogger(self.__class__.__name__)
        self.log.addHandler(logging.StreamHandler())
        self.log.setLevel(logging.INFO)
        self.url = "http://%s:%s" % (host, port)
        self.log.info("Connecting to %s" % self.url)
        self._server = Server(self.url)
        try:
            self._server.ping()
        except:
            raise EnvironmentError("Server unavailable")
        self._pdict = {}
        self.message = ""
        self.monitor = Monitoring(host)
        self.monitor.start()

    def commit(self, path, message):
        """
        Commit before running
        :param path: path to svn repository
        :param message: a commit message
        :return:
        """
        curdir = os.getcwd()
        self.message = message
        os.chdir(path)
        subprocess.check_call(["svn", "up"])
        subprocess.check_call(["svn", "commit", "-m", message])
        os.chdir(curdir)

    def set_parameters(self, pdict):
        """
        Run parameters
        :param pdict:
        :return:
        """
        self._pdict = pdict

    def execute(self, cleanup=True):
        """
        Execute the bugger
        :return:
        """
        res = None
        try:
            res = self._server.execute(self._pdict, cleanup)
        except KeyboardInterrupt:
            self.monitor.stop()
            server2 = Server(self.url)
            server2.kill()
        except socket.error:
            self.log.error("Server was interrupted")
            exit(1)
        finally:
            self.monitor.stop()
        if res is None:
            raise ValueError("Run failed")
        resstr = "%s\t%s\t %s\t %s\t %s\t %s\t %s" % (
            str(datetime.datetime.utcnow()), self.message,
            self._pdict["cpuRangeVal"], self._pdict["outputDir"],
            res["Wallclock"], res["peak"] / 1024.**3, res["avg"] / 1024**3)
        self.log.info(
            "date \t\t\t message \t\t cpu \t outputdir \t time \t peak_mem \t avg_mem"
        )
        self.log.info(resstr)
        with open(os.path.expanduser("~/result.dat"), "a") as out:
            out.write(resstr + "\n")
Пример #3
0
class Client(object):
    def __init__(self, host, port):
        super(Client, self).__init__()
        self.log = logging.getLogger(self.__class__.__name__)
        self.log.addHandler(logging.StreamHandler())
        self.log.setLevel(logging.INFO)
        self.url = "http://%s:%s" % (host, port)
        self.log.info("Connecting to %s" % self.url)
        self._server = Server(self.url)
        try:
            self._server.ping()
        except:
            raise EnvironmentError("Server unavailable")
        self._pdict = {}
        self.message = ""
        self.monitor = Monitoring(host)
        self.monitor.start()

    def commit(self, path, message):
        """
        Commit before running
        :param path: path to svn repository
        :param message: a commit message
        :return:
        """
        curdir = os.getcwd()
        self.message = message
        os.chdir(path)
        subprocess.check_call(["svn", "up"])
        subprocess.check_call(["svn", "commit", "-m", message])
        os.chdir(curdir)

    def set_parameters(self, pdict):
        """
        Run parameters
        :param pdict:
        :return:
        """
        self._pdict = pdict

    def execute(self, cleanup=True):
        """
        Execute the bugger
        :return:
        """
        res = None
        try:
            res = self._server.execute(self._pdict, cleanup)
        except KeyboardInterrupt:
            self.monitor.stop()
            server2 = Server(self.url)
            server2.kill()
        except socket.error:
            self.log.error("Server was interrupted")
            exit(1)
        finally:
            self.monitor.stop()
        if res is None:
            raise ValueError("Run failed")
        resstr = "%s\t%s\t %s\t %s\t %s\t %s\t %s" % (str(datetime.datetime.utcnow()), self.message, 
                                                      self._pdict["cpuRangeVal"], self._pdict["outputDir"],
                                                      res["Wallclock"], res["peak"]/1024.**3, res["avg"]/1024**3)
        self.log.info("date \t\t\t message \t\t cpu \t outputdir \t time \t peak_mem \t avg_mem")
        self.log.info(resstr)
        with open(os.path.expanduser("~/result.dat"), "a") as out:
            out.write(resstr+"\n")