mirror of https://github.com/n1nj4sec/pupy.git
adding hibernate module
This commit is contained in:
parent
7b34d5fb90
commit
a7418d3c63
|
@ -0,0 +1,28 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from pupylib.PupyModule import config, PupyModule, PupyArgumentParser
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
__class_name__ = "hibernate"
|
||||||
|
|
||||||
|
|
||||||
|
@config(cat="admin")
|
||||||
|
class hibernate(PupyModule):
|
||||||
|
""" Close session during x hours """
|
||||||
|
|
||||||
|
dependencies = ['hibernate']
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def init_argparse(cls):
|
||||||
|
cls.arg_parser = PupyArgumentParser(prog="hibernate", description=cls.__doc__)
|
||||||
|
cls.arg_parser.add_argument('hours', type=int, help='time to sleep (in hours)')
|
||||||
|
|
||||||
|
def run(self, args):
|
||||||
|
sleep_secs = self.client.remote('hibernate', 'sleep_time')
|
||||||
|
ok = sleep_secs(args.hours)
|
||||||
|
if ok:
|
||||||
|
connect_back = datetime.now() + timedelta(hours=int(args.hours))
|
||||||
|
self.success('Session will be back at %s' % str(connect_back))
|
||||||
|
self.client.conn._conn.close()
|
||||||
|
else:
|
||||||
|
self.error('Failed to hibernate session')
|
|
@ -0,0 +1,10 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import pupy
|
||||||
|
|
||||||
|
|
||||||
|
def sleep_time(seconds):
|
||||||
|
try:
|
||||||
|
pupy.sleep = int(seconds) * 3600
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
return False
|
1017
pupy/pp.py
1017
pupy/pp.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue