Skip to content

Instantly share code, notes, and snippets.

@davidlenz
Last active June 16, 2018 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidlenz/874bb483362ea17f8f056bb911c8db1d to your computer and use it in GitHub Desktop.
Save davidlenz/874bb483362ea17f8f056bb911c8db1d to your computer and use it in GitHub Desktop.
Collect environment information and store to file.
import socket
import os, json
import pip, sys
import platform
env = {}
import aetros
env['aetros_version'] = aetros.__version__
env['python_version'] = platform.python_version()
env['python_executable'] = sys.executable
env['hostname'] = socket.gethostname()
env['variables'] = dict(os.environ)
if 'AETROS_SSH_KEY' in env['variables']: del env['variables']['AETROS_SSH_KEY']
if 'AETROS_SSH_KEY_BASE64' in env['variables']: del env['variables']['AETROS_SSH_KEY_BASE64']
env['pip_packages'] = sorted([[i.key, i.version] for i in pip.get_installed_distributions()])
print(env)
with open('conda_env_info.txt', 'w') as file:
file.write(json.dumps(env, ensure_ascii=False, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment