Shutdown Information
Silent install package for Shutdown Information
2.0-30
Security
Security
- package: tis-info-shutdown
- name: Shutdown Information
- version: 2.0-30
- categories: Security
- maintainer: WAPT Team,Tranquil IT,Jimmy PELÉ
- locale: all
- target_os: windows
- architecture: all
- signature_date:
- size: 9.75 Ko
package : tis-info-shutdown
version : 2.0-30
architecture : all
section : base
priority : optional
name : Shutdown Information
categories : Security
maintainer : WAPT Team,Tranquil IT,Jimmy PELÉ
description : Annoy user about how long their PC is on - Only work with WAPT Enterprise
depends :
conflicts :
maturity : PROD
locale : all
target_os : windows
min_wapt_version : 1.8.2
sources : Ennuyer l'utilisateur à propos de la durée d'allumage de son PC - Fonctionne seulement avec WAPT Enterprise
installed_size :
impacted_process :
description_fr : Gêne l'utilisateur quant à la durée d'utilisation de son PC - Ne fonctionne qu'avec WAPT Enterprise
description_pl : Denerwowanie użytkownika o tym, jak długo komputer jest włączony - Działa tylko z WAPT Enterprise
description_de : Verärgert den Benutzer darüber, wie lange sein PC eingeschaltet ist - Funktioniert nur mit WAPT Enterprise
description_es : Molestar al usuario sobre el tiempo que su PC está encendido - Sólo funciona con WAPT Enterprise
description_pt : Utilizador irritado sobre quanto tempo o seu PC está ligado - Trabalhar apenas com a WAPT Enterprise
description_it : Infastidisce l'utente per quanto tempo il suo PC rimane acceso - Funziona solo con WAPT Enterprise
description_nl : De gebruiker ergeren over hoe lang hun PC aanstaat - Werkt alleen met WAPT Enterprise
description_ru : Раздражает пользователя тем, как долго включен его компьютер - Работает только с WAPT Enterprise
audit_schedule : 3h
editor :
keywords :
licence :
homepage :
package_uuid : 6b89e942-ca86-4066-8f5b-c72f12ab3e24
valid_from :
valid_until :
forced_install_on :
changelog :
min_os_version :
max_os_version :
icon_sha256sum : d9bb8c943e30af428be08e0ba3175a9320c235be8a950e086203c89e0dbd106f
signer : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature : Vmd04lcxPwxoZrTJFf2Wnz27tM65b8SMDEWxZ7RiF07Jzh9VnctvIRe8wF9IYnc0Sekq50zTnWaPtjUoD0PwKEVI9+p3p0UtyrZZEerdyVdqrO6aXtMl4M/lO5hqr35MQdGFTa2eDlAwEFTRpHW1NYIfx2OF8wmHmniGI+XAkEcBzIJryrkmV8EMGSroC+a0/Zazpebu6pZTchVAMyf0moMgsTVJBXyaEvusbN1GShjvfquI5NNP0iu63FvR5ppDsrmirSU7XKxpeoWHXKB2dXKQC73mzncvTjXi6qZ7DXDu5XuULlohhv1hA4zKye2SsKEonqLlJWY69AhaKDoYng==
signature_date : 2022-08-17T18:01:00.572261
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,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,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
# -*- coding: utf-8 -*-
from setuphelpers import *
import psutil
import time
import datetime
import ctypes
try:
from waptenterprise.waptservice.enterprise import get_active_sessions, start_interactive_process
except:
from waptservice.enterprise import get_active_sessions, start_interactive_process
import win32api
import sys
import platform
# Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
allow_force_reboot = False
boot_limit = 7 # In days
boot_limit_max = 30 # In days
force_reboot_timeout = 7200 # In seconds
message_box_title = "Information message about your PC uptime - The IT Support"
message_box_title_fr = "Message d'information à propos de la durée d'allumage du PC - Le Support Informatique"
# boot_limit_message = "This PC must be reboot because he's up since too long, Would you like to reboot now?"
boot_limit_message_string = "This PC must be rebooted because he's up since: %s, Would you like to reboot now?"
boot_limit_message_fr_string = "Ce PC doit être redémarré, car il est allumé depuis : %s, Voulez-vous redémarrer maintenant ?"
# boot_limit_max_message = "This PC will be FORCE reboot in 2 hours because he's up since too long"
boot_limit_max_message_string = "This PC will be FORCE reboot in %s hours because he's up since: %s"
boot_limit_max_message_fr_string = "Ce PC va être redémarré de manière FORCÉ dans %s heures, car il est allumé depuis : %s"
def install():
pass
r""" # Initializing variables
wapt_enterprise_dir = makepath(WAPT.wapt_base_dir,'waptenterprise')
# Checking that the WAPT Agent is well in Enterprise version
if isdir(wapt_enterprise_dir):
print('Continuing: WAPT Agent is well installed in Enterprise version')
else:
error('WAPT Agent is NOT installed in Enterprise version, please upgrade')
"""
def session_setup():
print("This PC is up since:")
print(convert_time_to_date(uptime_seconds()))
# Translating message
if get_language() == "fr":
message_box_title = message_box_title_fr
boot_limit_message_string = boot_limit_message_fr_string
boot_limit_max_message_string = boot_limit_max_message_fr_string
# Avoiding user pop-up spamming
check_timeout = 1800
date_format = "%Y-%m-%d %H:%M:%S" # datetime.datetime.strptime(date_pwsh, "%Y/%m/%d %H:%M:%S")
date = run_powershell('Get-Date -Format "yyyy-MM-dd HH:mm:ss"') # datetime.datetime.now()
date_reg = registry_readstring(HKEY_CURRENT_USER, r"SOFTWARE\WAPT\Shutdown Information", "Last Check")
if date_reg != "":
date_diff = datetime.datetime.strptime(date, date_format) - datetime.datetime.strptime(date_reg, date_format)
if date_diff.total_seconds() < check_timeout:
return "Already checked"
registry_set(HKEY_CURRENT_USER, r"SOFTWARE\WAPT\Shutdown Information", "Last Check", date)
# Notify the user
if allow_force_reboot:
if uptime_days() > boot_limit_max:
message_box(
message_box_title,
boot_limit_max_message_string % (convert_time_to_hours(force_reboot_timeout), convert_time_to_date(uptime_seconds(), translate=True)),
)
reboot_machine(force=1, timeout=force_reboot_timeout)
return "ERROR"
if uptime_days() > boot_limit:
message_box_ask_reboot(message_box_title, boot_limit_message_string % convert_time_to_date(uptime_seconds(), translate=True))
return "WARNING"
if uptime_days() < boot_limit:
return "OK"
def audit():
print("This PC is up since:")
print(convert_time_to_date(uptime_seconds()))
if allow_force_reboot:
if uptime_days() > boot_limit_max:
run_session_setup(control.package)
print("Force rebooting the PC after the defined timeout.")
reboot_machine(force=1, timeout=force_reboot_timeout)
return "ERROR"
if uptime_days() > boot_limit:
run_session_setup(control.package)
return "WARNING"
if uptime_days() < boot_limit:
return "OK"
def run_session_setup(package_name):
for session_id in get_active_sessions():
start_interactive_process("wapt-get", "--hide session-setup %s -f" % package_name, session_id=session_id) # , minimize=True
def message_box(title, text, style=0):
if platform.python_version_tuple()[0] == "3":
import importlib
importlib.reload(sys)
else:
reload(sys)
sys.setdefaultencoding("utf-8")
MB_OK = 0
MB_OKCANCEL = 1
MB_YESNOCANCEL = 3
MB_YESNO = 4
ctypes.windll.user32.MessageBoxW(0, "%s" % text, "%s" % title, style)
return
def message_box_ask_reboot(title, text):
if platform.python_version_tuple()[0] == "3":
import importlib
importlib.reload(sys)
else:
reload(sys)
sys.setdefaultencoding("utf-8")
ID_OK = 0
ID_CANCEL = 2
ID_ABORT = 3
ID_YES = 6
ID_NO = 7
response = ctypes.windll.user32.MessageBoxW(0, "%s" % text, "%s" % title, 4)
if response == ID_YES:
reboot_machine()
else:
pass
def uptime_seconds():
return time.time() - psutil.boot_time()
def uptime_minutes():
return (time.time() - psutil.boot_time()) / 60
def uptime_hours():
return (time.time() - psutil.boot_time()) / 3600
def uptime_days():
return ((time.time() - psutil.boot_time()) / 3600) / 24
def convert_time_to_hours(seconds):
return seconds / 3600
def convert_time_to_date(seconds, translate=False):
from datetime import datetime, timedelta
sec = timedelta(seconds=seconds)
d = datetime(1, 1, 1) + sec
# print("DAYS:HOURS:MIN:SEC")
# up 23 weeks, 3 days, 23 hours, 16 minutes
# up 23 weeks 3 days 23 hours 16 minutes
if translate:
if get_language() == "fr":
return "%d jours %d heures %d minutes %d secondes" % (d.day - 1, d.hour, d.minute, d.second)
return "%d days %d hours %d minutes %d seconds" % (d.day - 1, d.hour, d.minute, d.second)
# -*- coding: utf-8 -*-
from setuphelpers import *
def update_package():
# Incrementing version of the package
control.version = "%s-%s" % (control.get_software_version(), int(control.version.split("-")[-1]) + 1)
control.save_control_to_wapt()
print("Changing version to: %s in WAPT\\control" % control.version)
d9eeccf2b13f6a650a062c92df55881af38668125db07f4f7618041f9c84c391 : setup.py
054ff2cedec11ef86aa658b4365f11fa8742c241a43ca74657ff04b28a116576 : update_package.py
d9bb8c943e30af428be08e0ba3175a9320c235be8a950e086203c89e0dbd106f : WAPT/icon.png
a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf : WAPT/certificate.crt
09d2f4027795afcd146d3f63b7f34c148a358dc6b56d13f841d3c7f2c13b0974 : luti.json
7fa49c1cbae1dc02cf67e6a73f5a7de4b301bd22c20b9e8edfc8de07deb41dbf : WAPT/control