Ejemplo n.º 1
0
def daemon(args):
    import sddaemon, sdconfig

    if args.action is None:
        sddaemon.print_daemon_status()
    else:

        if args.action in ['start', 'stop']:
            if sdconfig.system_pkg_install:
                print_stderr(
                    "Daemon must be managed using 'service' command (system package installation)"
                )
                return 1

        if args.action == "start":

            if sddaemon.is_running():
                print_stderr("Daemon already started")
            else:
                try:
                    sddaemon.start()
                    print_stderr("Daemon successfully started")
                except sdexception.SDException, e:
                    print_stderr('error occured', e.msg)
        elif args.action == "stop":

            if sddaemon.is_running():
                try:
                    sddaemon.stop()
                    print_stderr("Daemon successfully stopped")
                except sdexception.SDException, e:
                    print_stderr('error occured', e.msg)
Ejemplo n.º 2
0
def daemon(args):
    import sddaemon,sdconfig

    if args.action is None:
        sddaemon.print_daemon_status()
    else:

        if args.action in ['start','stop']:
            if sdconfig.system_pkg_install:
                print_stderr("Daemon must be managed using 'service' command (system package installation)")
                return 1

        if args.action=="start":

            if sddaemon.is_running():
                print_stderr("Daemon already started")
            else:
                try:
                    sddaemon.start()
                    print_stderr("Daemon successfully started")
                except sdexception.SDException,e:
                    print_stderr('error occured',e.msg)
        elif args.action=="stop":

            if sddaemon.is_running():
                try:
                    sddaemon.stop()
                    print_stderr("Daemon successfully stopped")
                except sdexception.SDException,e:
                    print_stderr('error occured',e.msg)
Ejemplo n.º 3
0
def daemon(args):
    import sddaemon,sdconfig

    if args.action is None:
        sddaemon.print_daemon_status()
    else:
        if args.action=="start":

            if sdconfig.multiuser:
                print_stderr("Daemon must be started using 'systemctl' command")
                return

            if sddaemon.is_running():
                print_stderr("Daemon already started")
            else:
                try:
                    sddaemon.start()
                    print_stderr("Daemon successfully started")
                except SDException,e:
                    print_stderr('error occured',e.msg)
        elif args.action=="stop":

            if sdconfig.multiuser:
                print_stderr("Daemon must be stopped using 'systemctl' command")
                return

            if sddaemon.is_running():
                try:
                    sddaemon.stop()
                    print_stderr("Daemon successfully stopped")
                except SDException,e:
                    print_stderr('error occured',e.msg)
Ejemplo n.º 4
0
def watch(args):
    import sdreport, sddaemon

    if sddaemon.is_running():
        sdreport.print_running_transfers()
    else:
        print_stderr('Daemon not running')
Ejemplo n.º 5
0
def watch(args):
    import sdreport, sddaemon

    if sddaemon.is_running():
        sdreport.print_running_transfers()
    else:
        print_stderr('Daemon not running')
Ejemplo n.º 6
0
def check_daemon():
    import sdconfig
    if sdconfig.prevent_daemon_and_modification:
        import sddaemon
        if sddaemon.is_running():
            print 'The daemon must be stopped before installing/removing dataset'
            sys.exit(3)
Ejemplo n.º 7
0
def daemon(args):
    import sddaemon

    if len(args.parameter)==0:
        sddaemon.print_daemon_status()
    else:
        action=args.parameter[0] # it's a naming mess: rename top level action as subcommand
        if action=="start":
            if sddaemon.is_running():
                print_stderr("Daemon already started")
            else:
                try:
                    sddaemon.start()
                    print_stderr("Daemon successfully started")
                except SDException,e:
                    print_stderr('error occured',e.msg)
        elif action=="stop":
            if sddaemon.is_running():
                try:
                    sddaemon.stop()
                    print_stderr("Daemon successfully stopped")
                except SDException,e:
                    print_stderr('error occured',e.msg)
Ejemplo n.º 8
0
                from sdexception import SDException
                raise SDException('SDASYNDA-001','Unknown type (%s)'%args.type_)

            args.stream=stream # hack: pass 'stream' object downstream as a standalone argument (not inside args)

            import sdtsaction
            sdtsaction.actions[args.action](args)

        elif args.action in ['remove','install','stat']:
            # those actions systematically trigger full search (i.e. limit keyword cannot be used here)

            # check
            if sdconfig.prevent_daemon_and_modification:
                if args.action in ['remove','install']:
                    import sddaemon
                    if sddaemon.is_running():
                        print 'The daemon must be stopped before installing/removing dataset'
                        sys.exit(3)

            if sdstream.is_empty(stream):
                print 'No packages will be installed, upgraded, or removed.'
            else:

                # memo tuning: until this point, it go fast

                # Set the sdtream type.
                # Note that we 'force' (i.e. not 'default') the parameter here, so to prevent user to set it
                # (i.e. the type is always SA_TYPE_FILE when we are here).
                sddeferredbefore.add_forced_parameter(stream,'type',sdconst.SA_TYPE_FILE)

                import sdsearch
Ejemplo n.º 9
0
def _install(metadata, interactive, timestamp_right_boundary=None):
    import sddaemon

    # Compute total files stat
    count_total = metadata.count()
    size_total = metadata.size

    sdlog.info("SYNDINST-001", "'keep new status' process begins")

    # Compute new files stat
    #
    # (yes, block below is a duplicate of what is done inside sdenqueue.run()
    # method, but safer to keep it there too, and should be no harm in term of
    # perfomance)
    #
    import sdsimplefilter, sdconst
    metadata = sdsimplefilter.run(metadata, 'status',
                                  sdconst.TRANSFER_STATUS_NEW, 'keep')
    metadata = sdsimplefilter.run(metadata, 'url', "//None", 'remove_substr')
    count_new = metadata.count()
    size_new = metadata.size

    sdlog.info("SYNDINST-024", "'keep new status' process ends")

    # what to do if no match
    if count_new < 1:

        if count_total > 0:
            sdlog.info(
                "SYNDINST-027",
                "Nothing to install (matching files are already installed or waiting in the download queue). To monitor transfers status and progress, use 'synda queue' command.",
                stderr=interactive)
        else:
            sdlog.info("SYNDINST-028",
                       'Nothing to install (0 file found).',
                       stderr=interactive)

        return (0, 0)

    # ask user for confirmation
    if interactive:
        import humanize
        print_stderr('%i file(s) will be added to the download queue.' %
                     count_new)
        print_stderr(
            'Once downloaded, %s of additional disk space will be used.' %
            humanize.naturalsize(size_new, gnu=False))

        import sdutils
        if sdutils.query_yes_no('Do you want to continue?', default="yes"):
            installation_confirmed = True
        else:
            installation_confirmed = False
    else:
        installation_confirmed = True

    sdlog.info("SYNDINST-002", "Store metadata in database..")

    # install
    if installation_confirmed:
        import sdenqueue
        sdenqueue.run(metadata, timestamp_right_boundary)

        if interactive:
            print_stderr("%i file(s) enqueued" % count_new)
            print_stderr(
                "You can follow the download using 'synda watch' and 'synda queue' commands"
            )

            if not sddaemon.is_running():
                msg = sdi18n.m0025 if sdconfig.system_pkg_install else sdi18n.m0026
                print_stderr(
                    "The daemon is not running. To start it, use '%s'." % msg)
    else:
        if interactive:
            print_stderr('Abort.')

    sdlog.info("SYNDINST-025", "Task complete")

    return (0, count_new)
Ejemplo n.º 10
0
def _install(metadata,interactive,timestamp_right_boundary=None):
    import sddaemon


    # Compute total files stat
    count_total=metadata.count()
    size_total=metadata.size

    sdlog.info("SYNDINST-001","'keep new status' process begins")

    # Compute new files stat
    #
    # (yes, block below is a duplicate of what is done inside sdenqueue.run()
    # method, but safer to keep it there too, and should be no harm in term of
    # perfomance)
    #
    import sdsimplefilter, sdconst
    metadata=sdsimplefilter.run(metadata,'status',sdconst.TRANSFER_STATUS_NEW,'keep')
    count_new=metadata.count()
    size_new=metadata.size

    sdlog.info("SYNDINST-024","'keep new status' process ends")

    # what to do if no match
    if count_new<1:

        if count_total>0:
            sdlog.info("SYNDINST-027","Nothing to install (matching files are already installed or waiting in the download queue). To monitor transfers status and progress, use 'synda queue' command.",stderr=interactive)
        else:
            sdlog.info("SYNDINST-028",'Nothing to install (0 file found).',stderr=interactive)

        return (0,0)

    # ask user for confirmation
    if interactive:
        import humanize
        print_stderr('%i file(s) will be added to the download queue.'%count_new)
        print_stderr('Once downloaded, %s of additional disk space will be used.'%humanize.naturalsize(size_new,gnu=False))

        import sdutils
        if sdutils.query_yes_no('Do you want to continue?', default="yes"):
            installation_confirmed=True
        else:
            installation_confirmed=False
    else:
        installation_confirmed=True

    sdlog.info("SYNDINST-002","Store metadata in database..")

    # install
    if installation_confirmed:
        import sdenqueue
        sdenqueue.run(metadata,timestamp_right_boundary)

        if interactive:
            print_stderr("%i file(s) enqueued"%count_new)
            print_stderr("You can follow the download using 'synda watch' and 'synda queue' commands")

            if not sddaemon.is_running():
                msg=sdi18n.m0025 if sdconfig.system_pkg_install else sdi18n.m0026
                print_stderr("The daemon is not running. To start it, use '%s'."%msg)
    else:
        if interactive:
            print_stderr('Abort.')

    sdlog.info("SYNDINST-025","Task complete")

    return (0,count_new)
Ejemplo n.º 11
0
        else:
            installation_confirmed=False
    else:
        installation_confirmed=True


    # install
    if installation_confirmed:
        import sdenqueue
        sdenqueue.run(files)

        if interactive:
            print_stderr("%i file(s) enqueued"%count_new)
            print_stderr("You can follow the download using 'synda watch' and 'synda queue' commands")

            if not sddaemon.is_running():
                print_stderr("The daemon is not running. To start it, use 'sudo service synda start'.")
    else:
        if interactive:
            print_stderr('Abort.')

    return count_new

def intro(args):
    import sdi18n
    print sdi18n.m0019

def metric(args):
    import sdmetric,sdparam

    # check