From 1b5a1af7aa1aa67ee1cdab23b509bad077ddeb07 Mon Sep 17 00:00:00 2001 From: Alessandro ZANNI Date: Mon, 3 Oct 2016 16:44:41 +0200 Subject: [PATCH] list drives --- pupy/modules/drives.py | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/pupy/modules/drives.py b/pupy/modules/drives.py index 7e1ddf0b..0132b58a 100644 --- a/pupy/modules/drives.py +++ b/pupy/modules/drives.py @@ -1,26 +1,22 @@ # -*- coding: UTF8 -*- from pupylib.PupyModule import * -import ctypes +# import ctypes +from pupylib.utils.rpyc_utils import redirected_stdio __class_name__="Drives" @config(compat="windows", category="admin") class Drives(PupyModule): - """ List valid drives in the system """ - - def init_argparse(self): - self.arg_parser = PupyArgumentParser(prog="drives", description=self.__doc__) + """ List valid drives in the system """ + + dependencies=["win32api","win32com","pythoncom","winerror"] + + def init_argparse(self): + self.arg_parser = PupyArgumentParser(prog="drives", description=self.__doc__) - def run(self, args): - blen = self.client.conn.modules['ctypes'].c_uint(128) - rv = self.client.conn.modules['ctypes'].c_uint() - bufs = self.client.conn.modules['ctypes'].create_string_buffer(128) - rv = self.client.conn.modules['ctypes'].windll.kernel32.GetLogicalDriveStringsA(blen, bufs) - if rv == 0: - self.log('Error retrieving logical drives') - drives = bufs.raw.split('\0') - for drive in drives: - if drive: - self.log('- %s' % drive) - else: - break + def run(self, args): + self.client.load_package("wmi") + self.client.load_package("pupwinutils.drives") + + with redirected_stdio(self.client.conn): + self.client.conn.modules['pupwinutils.drives'].list_drives() \ No newline at end of file