Ejemplo n.º 1
0
 def ProceService(self):
     app = ServiceManager(self.ServiceName)
     if False == app.is_exists():
         self.logger.error('%s not exists' % self.ServiceName)
         return
     app_status = str(app.status())
     self.logger.info('%s status is:%s ' % (self.ServiceName, app_status))
     if 'RUNNING' in app_status:
         return
     else:
         self.logger.info('PythonService is death now reboot............')
         result = str(app.restart())
         self.logger.info('restart %s  result:%s' %
                          (self.ServiceName, result))
Ejemplo n.º 2
0
	def __init__(self):
		""""""
		if not shared.configuration.configured:
			logger.warning("No configuration found!")

		#events system
		shared.events = Events()

		shared.max_downloads = shared.configuration.get_max_downloads()
		shared.max_download_speed = shared.configuration.get_max_download_speed()

		ServiceManager.__init__(self)
		self.history = History()
		self.download_manager = DownloadManager(self.get_download_plugin, self.services)
Ejemplo n.º 3
0
    def __init__(self):
        """"""
        if not shared.configuration.configured:
            logger.warning("No configuration found!")

        #events system
        shared.events = Events()

        shared.max_downloads = shared.configuration.get_max_downloads()
        shared.max_download_speed = shared.configuration.get_max_download_speed(
        )

        ServiceManager.__init__(self)
        self.history = History()
        self.download_manager = DownloadManager(self.get_download_plugin,
                                                self.services)
 def RemoveService(self, ServiceName, ServicePath):
     app = ServiceManager(ServiceName)
     count = 0
     if False == app.is_exists():
         self.trigger.emit({'info': '%s服务已删除!' % ServiceName})
         return True
     while True:
         if count > 5:
             self.trigger.emit({'info': '%s服务已标记为删除,请稍后再查看!' % ServiceName})
             return False
         if False == app.is_exists():
             self.trigger.emit({'info': '%s服务已删除!' % ServiceName})
             return True
         cmd = '{0} remove'.format(os.path.join(self.local, ServicePath))
         os.system(cmd)
         time.sleep(5)
         count = count + 1
         self.trigger.emit(
             {'info': '正在删除%s服务,请稍后..........!' % ServiceName})
 def install_service(self, ServiceName, ServicePath):
     count = 0
     app = ServiceManager(ServiceName)
     self.trigger.emit({'info': '正在%s启动服务,请稍后!............' % ServiceName})
     if False == app.is_exists():
         while True:
             if count > 3:
                 self.trigger.emit({'info':
                                    '%s服务安装失败' % ServiceName})  # 发送信号
                 return False
             cmd = '{0} --startup auto install'.format(
                 os.path.join(self.local, ServicePath))
             os.system(cmd)
             if True == app.is_exists():
                 self.trigger.emit({'info':
                                    '%s服务安装成功' % ServiceName})  # 发送信号
                 break
             time.sleep(5)
             count = count + 1
     self.trigger.emit({'info': '%s服务安装成功' % ServiceName
                        })  # 发送信('PythonService 服务安装成功!')
     if 'RUNNING' not in str(app.status()):
         count = 0
         while True:
             if count > 5:
                 self.trigger.emit({'info':
                                    '%s服务启动失败!' % ServiceName})  # 发送信号
                 return False
             app.restart()
             if 'RUNNING' in str(app.status()):
                 self.trigger.emit({'info': '%s服务启动成功!' % ServiceName})
                 return True
             time.sleep(5)
             count = count + 1
             self.trigger.emit(
                 {'info':
                  '%s服务启动失败,第%d次重试!' % (ServiceName, count)})  # 发送信号
     else:
         self.trigger.emit({'info': '%s服务已启动!' % ServiceName})
         return True
 def StopService(self, ServiceName):
     app = ServiceManager(ServiceName)
     self.trigger.emit({'info': '正在停止%s服务,请稍后!............' % ServiceName})
     if False == app.is_exists():
         self.trigger.emit({'info': '%s服务已停止!' % ServiceName})
         # self.trigger.emit({'status': False})  # 发送信号
         return False
     if 'STOPPING' not in str(app.status()):
         while True:
             app.stop()
             if 'STOPPED' in str(app.status()):
                 self.trigger.emit({'info': '%s服务已停止!' % ServiceName})
                 return True
             else:
                 time.sleep(2)
     else:
         self.trigger.emit({'info': '%s服务已停止!' % ServiceName})
         return True
Ejemplo n.º 7
0
from pymongo import MongoClient
from service_manager import ServiceManager
import json
from bson import json_util
from bson.objectid import ObjectId
import base64
import onetimepass
import os
from enums import Mode, LoginStates
from datetime import datetime, timedelta
import utils
from generator import TestGenerator

_test_generator = TestGenerator(__name__)

service_name = ServiceManager.get_service_name(__name__)
_celery = Celery(service_name,
                 backend=ServiceManager.get_backend(service_name),
                 broker=ServiceManager.get_broker(service_name))


@_celery.task
@_test_generator.create()
def create_user(username, password, role, permissions):
    existing_user = ApiAccess.get_skynet_db().users.find_one(
        {'username': username.upper()})

    if existing_user is None:
        ApiAccess.get_skynet_db().users.insert_one({
            'username':
            username.upper(),
Ejemplo n.º 8
0
	def stop_all(self):
		""""""
		self.download_manager.quit()
		ServiceManager.stop_all(self)
Ejemplo n.º 9
0
# -*- coding: utf-8 -*-
"""
Copyright (C) 2017 tianyou pan <sherry0429 at SOAPython>
"""
# -*- coding:utf-8 -*-
from service_manager import ServiceManager

manager = ServiceManager()
data = manager.call("things")
 def Get_Server_Status(self):
     app = ServiceManager('PythonService')
     if False == app.is_exists():
         self.statusBar.showMessage('服务未安装!')
         return
     self.statusBar.showMessage('服务的运行状态为:%s' % app.status())
Ejemplo n.º 11
0
"""
This module bootstraps the API setup and registers all of the available services.
"""

from flask import request
from flask_api import FlaskAPI
from service_manager import ServiceManager
from services.sample import sample_service
from src.services.notes.notes import notes_list, notes_detail

app = FlaskAPI(__name__)
api = ServiceManager(app)


@api.route('/')
def index():
    """
    Displays the available services.

    :return: A dictionary of registered endpoints.
    """
    return api.formatted_routes(request.host_url)


@app.errorhandler(404)
def page_not_found(e):
    """
    Handles 404 errors experienced by the clients.

    :param e: The exception object
    :return: The exception object
Ejemplo n.º 12
0
        service.add_reverse_dependencies()

    for service in services:
        print(service)
    return services


def start_program(manager):
    while True:
        print("Select any option to start/stop the services ")
        print("1: start")
        print("2: stop")
        print("3: exit")
        option = input("Enter the option ")
        if option.lower() in ['start', '1']:
            print("Starting the services")
            manager.start_services()
        elif option.lower() in ['stop', '2']:
            manager.stop_services()
            print("Stoping the services")
        elif option.lower() in ['exit', '3']:
            print("Exiting the Program")
            exit()


if __name__ == '__main__':
    print("Starting Program")
    configs = load_config()
    manager = ServiceManager(get_services(configs))
    start_program(manager)
Ejemplo n.º 13
0
from service_manager import ServiceManager

###############################################################################
if __name__ == "__main__":
    # TODO Possibly segregate each service into their own files, along with
    # the option to add them to the manager at runtime. Rather than having them
    # added to the manager on initialization within code. Not exactly sure how
    # clean that would be opposed to the current functionality.
    sm = ServiceManager()
Ejemplo n.º 14
0
 def stop_all(self):
     """"""
     self.download_manager.quit()
     ServiceManager.stop_all(self)