mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
Blacken
This commit is contained in:
parent
dbec882589
commit
5eabcd8ee4
1 changed files with 15 additions and 3 deletions
|
@ -2,10 +2,12 @@
|
|||
|
||||
import os
|
||||
import hashlib
|
||||
import sys
|
||||
|
||||
CK_PATH = "/var/cache/salt/minion/dpkg.cookie"
|
||||
DPKG_PATH = "/var/lib/dpkg/status"
|
||||
|
||||
|
||||
def _get_mtime():
|
||||
"""
|
||||
Get the modified time of the Package Database.
|
||||
|
@ -35,9 +37,19 @@ def dpkg_post_invoke():
|
|||
"""
|
||||
Hook after the package installation transaction.
|
||||
"""
|
||||
if 'SALT_RUNNING' not in os.environ:
|
||||
with open(CK_PATH, 'w') as ck_fh:
|
||||
ck_fh.write('{chksum} {mtime}\n'.format(chksum=_get_checksum(), mtime=_get_mtime()))
|
||||
if "SALT_RUNNING" not in os.environ:
|
||||
try:
|
||||
ck_dir = os.path.dirname(CK_PATH)
|
||||
if not os.path.exists(ck_dir):
|
||||
os.makedirs(ck_dir)
|
||||
with open(CK_PATH, "w") as ck_fh:
|
||||
ck_fh.write(
|
||||
"{chksum} {mtime}\n".format(
|
||||
chksum=_get_checksum(), mtime=_get_mtime()
|
||||
)
|
||||
)
|
||||
except (IOError, OSError) as e:
|
||||
sys.stderr.write("Unable to save the cookie file: {}\n".format(e))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Reference in a new issue