Skip to content

Instantly share code, notes, and snippets.

@ViktorOgnev
Last active October 20, 2017 13:50
Show Gist options
  • Save ViktorOgnev/2dd79d1990a33f3f04e4 to your computer and use it in GitHub Desktop.
Save ViktorOgnev/2dd79d1990a33f3f04e4 to your computer and use it in GitHub Desktop.
import os
import pprint
import subprocess
# input
custom_reqs_current = ""
omnibus_reqs_old = ""
fatmouse_agent_reqs = []
freeze = """Babel==2.2.0
git+https://github.com/Scalr/pychef.git@68faa6c70e5ab5264b44a69079b7eafa4512c76c
PyMySQL==0.5
Pygments==2.0.1
amqp==1.4.8
anyjson==0.3.3
argparse==1.4.0
billiard==3.3.0.22
git+https://github.com/boto/boto.git@d14d5ac260a811aff3e1e1f1b1801b1bae1920bb
git+https://github.com/Scalr/[email protected]
git+https://github.com/Scalr/python-cloudstack.git@ed4411d472b98e129cdadabb017dfe2099363834#egg=cloudstack-python-client
cffi==1.4.2
cryptography==1.0.1
debtcollector==1.1.0
docopt==0.6.2
enum34==1.1.2
funcsigs==0.4
futures==3.0.3
google-api-python-client==1.4.2
httplib2==0.9.2
idna==2.0
ip-associations-python-novaclient-ext==0.1
ipaddress==1.0.16
ipython==2.3.0
iso8601==0.1.11
keystoneauth1==2.1.0
kombu==3.0.32
mock==1.3.0
monotonic==0.5
msgpack-python==0.4.6
netaddr==0.7.18
netifaces==0.10.4
oauth2client==1.5.2
os-diskconfig-python-novaclient-ext==0.1.3
os-networksv2-python-novaclient-ext==0.25
os-virtual-interfacesv2-python-novaclient-ext==0.19
oslo.config==3.2.0
oslo.i18n==3.1.0
oslo.serialization==2.2.0
oslo.utils==3.3.0
pbr==1.8.1
pexpect==2.4
prettytable==0.7.2
psutil==3.1.1
pyOpenSSL==0.15.1
pyasn1==0.1.9
pyasn1-modules==0.0.8
pycparser==2.14
git+https://github.com/Scalr/python-augeas.git@5b4fe6568eca7866429180d82a7aed58ee824e37 ; sys_platform != 'win32'
python-cinderclient==1.4.0
python-keystoneclient==1.7.1
python-novaclient==2.29.0
python-swiftclient==2.6.0
pytz==2015.7
pyreadline==2.1 ; sys_platform == 'win32'
rackspace-auth-openstack==1.3
rackspace-novaclient==1.5
rax-default-network-flags-python-novaclient-ext==0.3.2
rax-scheduled-images-python-novaclient-ext==0.3.1
readline==6.2.4.1 ; sys_platform != 'win32'
requests==2.9.1
rsa==3.2.3
schematics==1.1.1
simplejson==3.8.1
six==1.10.0
stevedore==1.10.0
git+https://github.com/Scalr/python-subprocess32.git@10394b10d7c5a14e84730ba49e213f92221fcec7 ; sys_platform != 'win32'
uritemplate==0.6
WMI==1.4.9 ; sys_platform == 'win32'
wrapt==1.10.6"""
# output
result = {'fatmouse': [], 'scalarizr': [], '2ndlevel': []}
ldr = os.listdir('omnibus/config/software/')
custom_reqs_current = [name.replace('python-', '').rstrip('.rb')
for name in ldr
if name.startswith('python-')]
with open('fatmouse/provision/requirements/agent.txt', 'r+') as fp:
for line in fp.readlines():
if '==' in line:
fatmouse_agent_reqs.append(line.split('==')[0])
if 'github.com' in line:
fatmouse_agent_reqs.append(line.split('@')[0])
HEAD = subprocess.check_output('git rev-parse HEAD', shell=True)
subprocess.check_call('git checkout -qf 64d8e89', shell=True)
ldr = os.listdir('omnibus/config/software/')
omnibus_reqs_old = [name.replace('python-', '').rstrip('.rb')
for name in ldr
if name.startswith('python-')]
subprocess.check_call('git reset --hard {}'.format(HEAD), shell=True)
for line in freeze.splitlines():
if '==' in line:
name = line.split('==')[0]
elif 'github.com' in line:
name = line.split('@')[0]
print('name is {} \nline is {}'.format(name, line))
if any(r1 for r1 in fatmouse_agent_reqs if name.lower() in r1.lower()):
result['fatmouse'].append(line)
continue
if line.startswith('python-') or any(r1 for r1 in omnibus_reqs_old if name.lower() in r1.lower()):
result['scalarizr'].append(line)
continue
result['2ndlevel'].append(line)
pprint.pprint(result)
lenresult = sum(len(v) for v in result.values())
lenfreeze = len([line for line in freeze.splitlines() if len(line.strip()) > 1])
print("num deps \n in freeze: {} \nin result {}".format(lenresult, lenfreeze))
content = """
fatmouse = "
{}
"
scalarir = "
{}
"
2ndlevel = "
{}
"
""".format(
'\n'.join(result['fatmouse']),
'\n'.join(result['scalarizr']),
'\n'.join(result['2ndlevel'])
)
with open('split_result', 'w+') as fp:
fp.write(content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment