def test_version_higher(self): req_ver = "100.100.100" e = ( "Script and API Version mismatch.*version {}, required {}" ).format(pytan.__version__, req_ver) with self.assertRaisesRegexp(Exception, e): utils.version_check(req_ver)
def csvdictwriter(rows_list, **kwargs): """returns the rows_list (list of dicts) as a CSV string""" csv_io = io.BytesIO() headers = kwargs.get('headers', []) or get_all_headers(rows_list) writer = csv.DictWriter( csv_io, fieldnames=headers, quoting=csv.QUOTE_NONNUMERIC, ) writer.writerow(dict((h, h) for h in headers)) writer.writerows(rows_list) csv_str = csv_io.getvalue() return csv_str if __name__ == "__main__": utils.version_check(__version__) parser = utils.CustomArgParse( description=__doc__, add_help=True, formatter_class=utils.CustomArgFormat, ) auth_group = parser.add_argument_group('Tanium Authentication') auth_group.add_argument( '-u', '--username', required=False, action='store', dest='username', default=None, help='Name of user', )
def test_version_lower(self): self.assertTrue(utils.version_check('0.0.0'))
csv_file = '{}_{}.csv'.format(my_name, utils.get_now()) csv_file = filter_filename(csv_file) csv_file_path = os.path.join(report_dir, csv_file) csv_fh = open(csv_file_path, 'wb') csv_fh.write(csv_str) csv_fh.close() mylog.info("Final CSV results of {} written to: {}".format( story, csv_file_path)) if __name__ == "__main__": utils.version_check(__version__) parser = utils.CustomArgParse( description=__doc__, add_help=True, formatter_class=utils.CustomArgFormat, ) auth_group = parser.add_argument_group('Tanium Authentication') auth_group.add_argument( '-u', '--username', required=False, action='store', dest='username', default=None, help='Name of user', )