コード例 #1
0
ファイル: ui.py プロジェクト: LTurner-CT/shakecast
 def start_server(self):
     """
     Starts a Server if there isn't one running
     """
     print 'Starting server...'
     try:
         sc_server = Server()
         sc_server.silent = True
         sc_server.ui_open = True
         server_thread = New_Thread(func=sc_server.loop)
         server_thread.start()
     except:
         print 'failed'
コード例 #2
0
ファイル: ui.py プロジェクト: wald-usgs/shakecast
 def start_server(self):
     """
     Starts a Server if there isn't one running
     """
     print 'Starting server...'
     try:
         sc_server = Server()
         sc_server.silent = True
         sc_server.ui_open = True
         server_thread = New_Thread(func=sc_server.loop)
         server_thread.start()
     except:
         print 'failed'
コード例 #3
0
ファイル: routes.py プロジェクト: Teahaf/ZI
def add_file(id):
    files = Server.query.filter_by(user_id = id).all()
    alocated_memory = 0
    for filee in files:
        alocated_memory += filee.data_size
    user = User.query.filter_by(id = id).first()
    uploaded_data = get_data()
    if (alocated_memory + uploaded_data.get("size"))< user.max_size:
        name = uploaded_data.get("name")
        flag = 0
        for filee in files:
            if name == filee.name:
                flag+=1
        if flag > 0:
            name= name + "(" +  str(flag) + ")"
        path = "C:\\Users\\Hafner\\Desktop\\ZI\\Server\\Files\\" + name + ticks()
        import io
        with io.open(path, "a+", encoding="utf-8") as f:
            f.write(uploaded_data.get("data"))
        server = Server.create(Server, name, path, uploaded_data.get("hash"),uploaded_data.get("size"),id)
    else:
        return "Prevaziso si maximalnu dozvoljenu kolicinu podataka."
    if server:
        return server.to_dict()
    else:
        return {}
コード例 #4
0
ファイル: test_serializer.py プロジェクト: KiLlOrBe/PythTRT
    def test_serialize(self):
        req_matcher10 = RequestMatcher(policy=Policy.PRIORITIZE) \
            .add_domain_re(r'^intranet$') \
            .add_port(443)
        req_matcher11 = RequestMatcher(policy=Policy.PRIORITIZE) \
            .add_domain_re(r'^server-test$') \
            .add_port(8080)
        link1 = Link(interface="wlp5s0") \
            .add_request_matcher(req_matcher10) \
            .add_request_matcher(req_matcher11)
        req_matcher2 = RequestMatcher(policy=Policy.FORBID) \
            .add_domain_re(r'.com$')
        link2 = Link(interface="enp3s0", weight=2) \
            .add_request_matcher(req_matcher2)
        balancer_req_matcher = RequestMatcher(policy=Policy.ALLOW) \
            .add_port(443) \
            .add_port(80) \
            .add_port(8080)
        balancer = Balancer(strategy=Strategy.LEAST_CONNECTIONS) \
            .add_request_matcher(balancer_req_matcher) \
            .add_link(link1) \
            .add_link(link2)
        server = Server() \
            .set_balancer(balancer)

        serialized = serialize(server)
        deserialized = deserialize(serialized, Server)

        self.assertEqual(serialized, serialize(deserialized))

        save_server("test.json", server)
コード例 #5
0
    def __init__(self, parent = None):
        QtGui.QMainWindow.__init__(self, parent)
        
        self._ui = Ui_MainWindow()
        self._ui.setupUi(self)

        self.setWindowTitle("Linux Server Tools Manager")
        
        self.connect(self._ui.aServerAdd, QtCore.SIGNAL("triggered()"), self._action_add_server)
        self.connect(self._ui.aServerRemove, QtCore.SIGNAL("triggered()"), self._action_remove_server)
        self.connect(self._ui.aToolsSettings, QtCore.SIGNAL("triggered()"), self._action_open_settings)
        self.connect(self._ui.aHelpAbout, QtCore.SIGNAL("triggered()"), self._show_about)
        self.connect(self._ui.twServers, QtCore.SIGNAL("itemDoubleClicked(QTreeWidgetItem *,int)"), self._action_manage_server)
           
        self._updateTimer = QtCore.QTimer(self)
        self._updateTimer.setInterval(2000)
        self._updateTimer.setSingleShot(False)
        self.connect(self._updateTimer, QtCore.SIGNAL("timeout()"), self._update_list)
        self._updateTimer.start()
        
        self._servers = []
        
        self._settings = QtCore.QSettings("linux-server-tools", "manager")
        self._settings.beginGroup("ui")
        self.setGeometry(self._settings.value("geometry", self.geometry()))
        
        for i in range(6):
            self._ui.twServers.header().resizeSection(i, int(self._settings.value("col%d" % (i), self._ui.twServers.header().sectionSize(i))))
            
        self._settings.endGroup()
        
        self._settings.beginGroup("servers")
        
        for server in self._settings.childGroups():
            self._settings.beginGroup(server)
            
            s = Server(self._settings.value("addr"), int(self._settings.value("port")), str(self._settings.value("user")), (str(self._settings.value("key1")), str(self._settings.value("key2"))), str(self._settings.value("lstdir")), QtGui.QTreeWidgetItem(self._ui.twServers))
            s.set_info(server, self._settings.value("desc"))
            self._servers.append(s)
            
            self._settings.endGroup()            
                
        self._settings.endGroup()
        
        for s in self._servers:
            s.start()
コード例 #6
0
 def _add_server(self, name, desc, addr, port, user, keys, lstdir):
     server = Server(addr, port, user, keys, lstdir, QtGui.QTreeWidgetItem(self._ui.twServers))        
     
     self._settings.beginGroup("servers/%s" % (name))
     
     self._settings.setValue("desc", desc)
     self._settings.setValue("addr", addr)
     self._settings.setValue("port", 22)
     self._settings.setValue("user", user)
     self._settings.setValue("key1", keys[0])
     self._settings.setValue("key2", keys[1])
     self._settings.setValue("lstdir", lstdir)
     self._settings.endGroup()        
     
     self._servers.append(server)
     server.set_info(name, desc)
     server.start()
コード例 #7
0
ファイル: routes.py プロジェクト: xudan16/dovetail
def get_testcases_status(exec_id):
    if 'testcase' not in request.json:
        return 'Need testcases list as input.\n', 400

    testcases = request.json['testcase']
    dovetail_home = os.getenv('DOVETAIL_HOME')

    server = Server(dovetail_home, exec_id, request.json)
    testcases_file = os.path.join(dovetail_home, str(exec_id), 'results',
                                  'testcases.json')
    with open(testcases_file, "r") as f:
        for jsonfile in f:
            data = json.loads(jsonfile)
        testsuite = data['testsuite']

    result = server.get_execution_status(testsuite, testcases,
                                         data['testcases'])

    return jsonify({'result': result}), 200
コード例 #8
0
    def add_user_to_new_server(self, user_count):
        """
        Cria-se um novo servidor, enquanto ele estiver disponível e existir usuários, um novo usuario é adicionado

        Parameters
        ----------
        user_count: Numero de usuarios

        Returns
        -------
        Numero de usuários remanescentes

        """
        server = Server()
        while server.available_server() is True and user_count > 0:
            server.add_user(User())
            user_count -= 1

        self.servers.append(server)
        return user_count
コード例 #9
0
ファイル: routes.py プロジェクト: xudan16/dovetail
def run_testcases():
    requestId = request.args.get('requestId')
    if not requestId:
        requestId = uuid.uuid1()
    if os.getenv('DOVETAIL_HOME'):
        dovetail_home = os.getenv('DOVETAIL_HOME')
    else:
        return 'No DOVETAIL_HOME found in env.\n', 500

    server = Server(dovetail_home, requestId, request.json)

    msg, ret = server.set_conf_files()
    if not ret:
        return msg, 500

    msg, ret = server.set_vm_images()
    if not ret:
        return msg, 500

    input_str = server.parse_request()

    repo_dir = os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
    run_script = os.path.join(repo_dir, 'run.py')

    cmd = 'python3 {} {}'.format(run_script, input_str)
    api_home = os.path.join(dovetail_home, str(requestId))
    subprocess.Popen(cmd,
                     shell=True,
                     env={
                         'DOVETAIL_HOME': api_home,
                         'LC_ALL': 'C.UTF-8',
                         'LANG': 'C.UTF-8'
                     })

    testcases_file = os.path.join(dovetail_home, str(requestId), 'results',
                                  'testcases.json')
    for loop in range(60):
        if not os.path.isfile(testcases_file):
            time.sleep(1)
        else:
            break
    else:
        return 'Can not get file testcases.json.\n', 500

    with open(testcases_file, "r") as f:
        for jsonfile in f:
            data = json.loads(jsonfile)
        testcases = data['testcases']
        testsuite = data['testsuite']

    result = server.get_execution_status(testsuite, testcases, testcases)

    return jsonify({'result': result}), 200
コード例 #10
0
    def main():
        logging.info(' ** Starting ShakeCast Server ** ')
        try:
            sc_server = Server()

            # start shakecast
            sc_server.start_shakecast()

            while sc_server.stop_server is False:
                sc_server.stop_loop = False
                sc_server.loop()

        except Exception as e:
            exc_tb = sys.exc_info()[2]
            filename, line_num, func_name, text = traceback.extract_tb(
                exc_tb)[-1]
            logging.info('{}: {} - line: {}\nOriginated: {} {} {} {}'.format(
                type(e), e, exc_tb.tb_lineno, filename, line_num, func_name,
                text))
        return
コード例 #11
0
    def main():
        logging.info(' ** Starting ShakeCast Server ** ')
        try:
            sc_server = Server()

            # start shakecast
            sc_server.start_shakecast()
            
            while sc_server.stop_server is False:
                sc_server.stop_loop = False
                sc_server.loop()

        except Exception as e:
            exc_tb = sys.exc_info()[2]
            filename, line_num, func_name, text = traceback.extract_tb(exc_tb)[-1]
            logging.info('{}: {} - line: {}\nOriginated: {} {} {} {}'.format(type(e), 
                                                                             e, 
                                                                             exc_tb.tb_lineno,
                                                                             filename, 
                                                                             line_num, 
                                                                             func_name, 
                                                                             text))
        return
コード例 #12
0
ファイル: main.py プロジェクト: pyduh/rabbit-mq-ds
if __name__ == '__main__':
    from app.server import Server

    server = Server()

    try:
        server.run()
    except KeyboardInterrupt:
        server.stop()
コード例 #13
0
ファイル: routes.py プロジェクト: xudan16/dovetail
def get_testcases():
    testcases = Server.list_testcases()
    return jsonify({'testcases': testcases}), 200
コード例 #14
0
#!/usr/bin/env python

from app.server import Server

if __name__ == '__main__':
  app = Server()
  app.run()
コード例 #15
0
ファイル: run.py プロジェクト: Judice/tornado_basic_frame
# -*- coding: utf-8 -*-

import tornado.options

from app.server import Server
from app.application import Application

if __name__ == "__main__":
    tornado.options.parse_command_line()
    app = Application()
    server = Server(app)
    server.run_server()
コード例 #16
0
ファイル: main.py プロジェクト: thiagortz/justice-league
from app.server import Server

if __name__ == "__main__":
    Server().start()
コード例 #17
0
ファイル: routes.py プロジェクト: xudan16/dovetail
def get_all_testsuites():
    testsuites = Server.list_testsuites()
    return jsonify({'testsuites': testsuites}), 200
コード例 #18
0
def main():
    Server().run()
コード例 #19
0
def main():
    cfg = json.load('config.json')
    server = Server(cfg)
    result = server.fct_test()
    print(result['status'])