upgrade to CAM v2.0
[stack/cam.git] / lib / utils.py
diff --git a/lib/utils.py b/lib/utils.py
deleted file mode 100644 (file)
index 813ddef..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-
-__all__ = [
-    'getcertdate', 'fingerprint', 'expired',
-    'cfg2dict', 'mkdir', 'template',
-    'dictmerge', 'd2get', 
-    'openssl'
-    ]
-
-
-import commands
-import os, re
-import time
-
-
-def getcertdate(crt_file):
-    if os.path.exists(crt_file):
-       o = commands.getoutput('openssl x509 -in %s -noout -dates' % crt_file)
-       m = re.search(r'notAfter=(.*)', o)
-       if m:
-           return time.mktime(time.strptime(m.group(1), 
-                                            '%b %d %H:%M:%S %Y %Z'))
-    return 0
-
-def expired(crtdate):
-    if crtdate < time.time():
-       return 1
-    else:
-       return 0
-
-def fingerprint(hash, crt_file):
-    if os.path.exists(crt_file):
-       o = commands.getoutput('openssl x509 -in %s -noout -fingerprint -%s' % (crt_file, hash))
-       m = re.search(r'=(.*)$', o)
-       if m:
-           return m.group(1)
-    return 'NOT FOUND'
-
-def cfg2dict(cfg, section):
-    d = dict()
-    for k, v in cfg.items(section):
-       d[k] = v
-    return d
-
-def mkdir(p):
-    try:
-       os.mkdir(p, 0755)
-       print 'created directory \'%s\'' % p
-    except OSError:
-       pass
-
-def template(file, t, args):
-    f = open(file, 'w')
-    f.write(t % args)
-    f.close()
-
-def dictmerge(d1, d2):
-    out = dict()
-    for d in [ d2, d1 ]:
-       for k, v in d.items():
-           out[k] = v
-    return out
-
-def d2get(d1, d2, k, default=None):
-    return d1.get(k, d2.get(k, default))
-
-def openssl(*args):
-    cmd = "openssl " + ' '.join(["'%s'" % x for x in args])
-    print 'executing "%s"' % cmd
-    return os.system(cmd)
-
-
-