Initial Commit

This commit is contained in:
Daniel Dayley 2021-07-15 10:17:43 -06:00
commit 209cbdb894
3 changed files with 83 additions and 0 deletions

23
README.md Normal file
View File

@ -0,0 +1,23 @@
# python-tool
## Description
## Usage
```
```
## Installation
1.
2.
3.
## Configuration
```
```
## Justification

41
bin/python-tool Normal file
View File

@ -0,0 +1,41 @@
#!python3
import os
import sys
import yaml
import logging
import argparse
if __name__ == '__main__':
# Command-line client
# Define constants
config_template = {'python-tool': {}}
# Gather Argument options
EXAMPLE_TEXT='Example:\n\tpython-tool '
parser = argparse.ArgumentParser(epilog=EXAMPLE_TEXT,formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-c', '--config', action='store', help='Specify a config file (./config.yml)',default='./config.yml')
parser.add_argument('-H', '--hosts', action='append', default=None, help='Collects arguments in an array.')
parser.add_argument('-d', '--dry-run', action='store_true', help='Store the existence of a variable.')
parser.add_argument('-l', '--log', action='store', help='Specify a file to log to.')
parser.add_argument('-v', '--debug', action='count', help='Include debug information in the output. Add \'v\'s for more output.',default=0)
args = parser.parse_args()
def debug(message,level) :
if args.debug >= level :
print(message,file=sys.stderr)
if args.log :
logging.basicConfig(level=logging.INFO,filename=args.log)
# Parse config
config_path = os.path.normpath(config_path)
file_descriptor = open(os.path.normpath(os.path.expanduser(os.path.expandvars(config_path))))
self._config = yaml.safe_load(file_descriptor)
if not isinstance(self._config,dict) :
raise ValueError('expected dictonary as top-level yaml object')
print('Hello World!')

19
setup.py Normal file
View File

@ -0,0 +1,19 @@
from setuptools import setup, find_packages
import glob
files = glob.glob('python-tool/externals/*.py')
setup(name='python-tool',
version='1.0.0',
url='',
license='Apache2',
author='Daniel Dayley',
author_email='github@cronocide.com',
description='',
packages=find_packages(exclude=['tests']),
package_data={"": ['externals/*.py']},
install_requires=['pyyaml', 'vsphere-automation-sdk @ git+https://github.com/vmware/vsphere-automation-sdk-python.git'],
scripts=['bin/python-tool'],
long_description=open('README.md').read(),
zip_safe=True
)