Esempio n. 1
0
def stop():
    try:
        # Send a SIGINT to a process denoted by a PID file
        send(PID_FILE_PATH, SIGINT)
        click.echo("Daemon stopped!")
    except Exception as e:
        click.echo("Daemon not started!")
Esempio n. 2
0
def stop(namespace=None):
    ''' Stops the Hypergolix daemon.
    '''
    with Config() as config:
        pid_file = str(config.pid_file)

    daemoniker.send(pid_file, SIGTERM)
Esempio n. 3
0
def stop(namespace=None):
    ''' Stops the Hypergolix daemon.
    '''
    with Config.find() as config:
        pid_file = str(config.process.pid_file)
        
    daemoniker.send(pid_file, SIGTERM)
Esempio n. 4
0
def exit_UIP():
    """Exit from UIP program."""
    pid_file = os.path.join(HOME_DIR, 'daemon-uip.pid')
    if os.path.exists(pid_file):
        send(pid_file, SIGTERM)
        os.remove(pid_file)
    print("\nExiting UIP hope you had a nice time :)")
    sys.exit(0)
Esempio n. 5
0
def logout(profile: Profile, session: Session):
    try:
        send(profile.pidfile, SIGINT)
        if os.path.exists(profile.pidfile):
            os.remove(profile.pidfile)
        remove_credentials(session)
    except IOError:
        raise AlreadyLoggedOut
Esempio n. 6
0
def stop(namespace=None):
    ''' Stops the Hypergolix daemon.
    '''
    if namespace.pidfile is not None:
        raise RuntimeError('Server pidfile specification through CLI is no ' +
                           'longer supported. Edit hypergolix.yml ' +
                           'configuration file instead.')
        
    config = Config.find()
    daemoniker.send(str(config.server.pid_file), SIGTERM)
Esempio n. 7
0
def main():
    settingsParser = ParseSettings()
    settings = settingsParser.settings
    pid_file = os.path.join(HOME_DIR, 'daemon-uip.pid')
    if settings['service']:
        if 'start' == str(settings['service']):
            with Daemonizer() as (is_setup, daemonizer):
                if is_setup:
                    print("UIP will now run as a serice.")
                try:
                    is_parent = daemonizer(pid_file)
                except SystemExit:
                    print("UIP service already, running "
                          "Close previous app by running UIP --service stop")

        elif 'stop' == str(settings['service']):
            try:
                send(pid_file, SIGTERM)
                os.remove(pid_file)
                sys.exit(0)
            except Exception as e:
                print("you need to start a service first", str(e))
                sys.exit(0)
        else:
            print('Wrong option for service flag see --help')

    print("Hey this is UIP! you can use it to download"
          " images from reddit and also to schedule the setting of these"
          " images as your desktop wallpaper."
          " \nPress ctrl-c to exit")
    try:
        if settings['error']:
            print("\nWRONG USAGE OF FLAGS --no-of-images AND --offline")
            settingsParser.show_help()
            sys.exit(0)
        if settings['offline']:
            print("You have choosen to run UIP in offline mode.")
        if settings['flush']:
            print("Deleting all downloaded wallpapers...")
            try:
                shutil.rmtree(settings['pics-folder'])
                os.mkdir(settings['pics-folder'])
            except FileNotFoundError:
                pass
        if not settings['offline']:
            print("UIP will now connect to internet and download images"
                  " from reddit and unsplash.")
        scheduler(settings['offline'], settings['pics-folder'],
                  settings['timeout'], settings['website'],
                  settings['no-of-images'])
    except KeyboardInterrupt:
        print("Exiting UIP hope you had a nice time :)")
        sys.exit(0)
def main(profile: Profile, session: Session):
    is_parent = True

    if profile.force_refresh:
        try:
            profile.raise_if_logged_in()
        except AlreadyLoggedIn:
            send(profile.pidfile, SIGINT)
            return

        logger.warn("Logged out: ignoring --force-refresh.")

    try:
        client = session.create_client('sts')

        # Exit if already logged in
        profile.raise_if_logged_in()

        # Must know username to lookup cookies
        profile.get_username()

        try:
            saml, roles = refresh(
                profile.ecp_endpoint_url,
                profile.cookies,
            )
        except Exception:
            creds = profile.get_credentials()
            saml, roles = authenticate(profile.ecp_endpoint_url,
                                       profile.cookies, *creds)

        duration = profile.duration
        role = get_selection(roles, profile.role_arn)
        expires = save_sts_token(session, client, saml, role, duration)

        if os.name == 'posix' and not profile.disable_refresh:
            is_parent = daemonize(profile, session, client, role, expires)
    except Exception:
        raise
    finally:
        if not is_parent:
            logger.info('Exiting refresh process')
Esempio n. 9
0
def logout(profile: Profile, session: Session):
    try:
        send(profile.pidfile, SIGINT)
        remove_credentials(session)
    except IOError:
        raise AlreadyLoggedOut
Esempio n. 10
0
     app = Telereader(telemeter_fingerprint)
     
     try:
         app.app_init()
         
         if args.interval is not None:
             app.set_interval(args.interval)
         
         app.app_run()
         
     finally:
         app.hgxlink.stop_threadsafe()
 
 # This is the SENDER, but we're stopping it.
 elif args.stop:
     daemoniker.send(args.pidfile, daemoniker.SIGTERM)
     
 # This is the SENDER, and we're starting it.
 else:
     # We need to actually daemonize the app so that it persists without
     # an SSH connection
     with daemoniker.Daemonizer() as (is_setup, daemonizer):
         is_parent, pidfile = daemonizer(
             args.pidfile,
             args.pidfile,
             strip_cmd_args = False
         )
         
         # Parent exits here
     
     # Just the child from here
Esempio n. 11
0
def stop(namespace=None):
    ''' Stops the Hypergolix daemon.
    '''
    daemoniker.send(namespace.pidfile, SIGTERM)