tis-schedule-wapt-upgrade-on-boot icon

Schedule WAPT Upgrade on Boot

Paquet d’installation silencieuse pour Schedule WAPT Upgrade on Boot

1.1-11

  • package: tis-schedule-wapt-upgrade-on-boot
  • name: Schedule WAPT Upgrade on Boot
  • version: 1.1-11
  • categories: System and network,Security
  • maintainer: Tranquil IT
  • target_os: windows
  • architecture: all
  • signature_date:
  • size: 9.95 Ko

package           : tis-schedule-wapt-upgrade-on-boot
version           : 1.1-11
architecture      : all
section           : base
priority          : standard
name              : Schedule WAPT Upgrade on Boot
categories        : System and network,Security
maintainer        : Tranquil IT
description       : Trigger "wapt-get upgrade" when the PC boot
depends           : 
conflicts         : 
maturity          : PROD
locale            : 
target_os         : windows
min_os_version    : 
max_os_version    : 
min_wapt_version  : 1.5
sources           : 
installed_size    : 
impacted_process  : 
description_fr    : Lance un "wapt-get upgrade" quand le PC démarre
description_pl    : 
description_de    : 
description_es    : 
description_pt    : 
description_it    : 
description_nl    : 
description_ru    : 
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : 4677b707-5c61-4835-90d7-e6e81abc73e0
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature         : MumlWlBcxsWkZyn7glT6ou4EYHUahTX8BLKd1vBV6H2cQydcjDDulImi5o4hDhOyH1qyEC126jDmcuBf+RWlXoIc3LGZZB8hTWcwK5kvgUp7U+xtwEybJzjZGFi79Bf9psZ9tmy6aytBp245tc9DhiK5dujGO1roJfiNWq+n03sbNkTg7ds/arfTZGuHngtA864UjjXZbVt1yjltF8YG3C5a1gTtdSPZg/rf9Ihqkw02kE47k1wctg01sG1kwaAUrGiUTXs7jPzrLfy4ERDj6cveR9BW2KNCL8qGMSQSzj/eJLq4vGIZCy8ywxRgTe8WO/2LVWoycaMLE0ZaxtmUFA==
signature_date    : 2020-11-13T11:45:26.641124
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_os_version,max_os_version,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,signer,signer_fingerprint,signature_date,signed_attributes

# -*- coding: utf-8 -*-
from setuphelpers import *
from setuphelpers_windows import *
uninstallkey = []

# Defining variables
task_name = 'WAPTupgradeOnBoot'


def install():
    # Creating the scheduled task
    if task_exists(task_name):
        delete_task(task_name)
    try:
        print('Creating the task: %s' % task_name)
        create_onboot_task(task_name,'wapt-get','-S upgrade')
    except:
        print('Unable to create the task: %s' % task_name)

    # Removing the old scheduled task
    if task_exists('auto-wapt-upgrade-on-boot'):
        try:
            delete_task('auto-wapt-upgrade-on-boot')
        except:
            print('Unable to disable the task: auto-wapt-upgrade-on-boot')


def uninstall():
    # Removing the scheduled task
    if task_exists(task_name):
        try:
            delete_task(task_name)
        except:
            print('Unable to disable the task: %s' % task_name)


def audit():
    if not task_exists(task_name):
        print("task %s don't exist, WAPT is installing package to fix that" % task_name)
        install()
        return "WARNING"
    if not enable_task(task_name):
        print("task %s is disable, WAPT is going to enable the task" % task_name)
        enable_task(task_name)
        return "WARNING"
    else:
        print("task %s exist and is active" % task_name)
        return "OK"


def update_package():
    # Initializing variables
    version = control.version.split('-')[0]

    # Incrementing version of the package
    control.version = '%s-%s'%(version,int(control.version.split('-')[-1])+1)
    control.save_control_to_wapt()
    print('Changing package version to: %s in WAPT\\control' % control.version)




def create_onboot_task(name, cmd, parameters, max_runtime=10):
    """creates a Windows scheduled task on boot and activate it.

    Args:
        name (str): name of task for reference
        cmd(str) :  command line
        parameters (str) : arguments to append to cmd
        max_runtime (int): maximum running time in minutes

    Returns:
        PyITask: scheduled task
    """
    ts = pythoncom.CoCreateInstance(taskscheduler.CLSID_CTaskScheduler, None,
                                    pythoncom.CLSCTX_INPROC_SERVER,
                                    taskscheduler.IID_ITaskScheduler)

    if '%s.job' % name not in ts.Enum():
        task = ts.NewWorkItem(name)

        task.SetApplicationName(cmd)
        task.SetParameters(parameters)
        task.SetAccountInformation('', None)
        if max_runtime:
            task.SetMaxRunTime(max_runtime * 60*1000)
        #task.SetFlags(task.GetFlags() | taskscheduler.TASK_FLAG_)
        ts.AddWorkItem(name, task)
        run_time = time.localtime(time.time() + 300)
        tr_ind, tr = task.CreateTrigger()
        tt = tr.GetTrigger()
        tt.Flags = 0
        tt.BeginYear = int(time.strftime('%Y', run_time))
        tt.BeginMonth = int(time.strftime('%m', run_time))
        tt.BeginDay = int(time.strftime('%d', run_time))
        tt.TriggerType = int(taskscheduler.TASK_EVENT_TRIGGER_AT_SYSTEMSTART)
        tr.SetTrigger(tt)
        pf = task.QueryInterface(pythoncom.IID_IPersistFile)
        pf.Save(None, 1)
        # task.Run()
    else:
        raise KeyError("%s already exists" % name)

    task = ts.Activate(name)
    #exit_code, startup_error_code = task.GetExitCode()
    return task


d9141d512ad35bc6d1f232d76f33288d2ad2b6daf7d8b6f6950e09b67892adff : setup.py
394a78606b3312802aca8be118327029c2e789ba97b377dd64673ef33d4e3587 : WAPT/icon.png
a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf : WAPT/certificate.crt
9332526aca8c88b03efe6ca43be64350c673f010758958593fb8dbdba29fecb6 : WAPT/control