Sub routine to run the application.
54def run(args: argparse.Namespace) -> int:
55 rc: int = 0
56 cwd = os.getcwd()
57
58 try:
59 while True:
61 'Listing Python virtual environments in "pyenv".'
62 )
64
65
66 versions_dir = os.path.join(
67 os.environ['PYENV_ROOT'],
68 'versions'
69 )
70 if not os.path.isdir(versions_dir):
71 log.error(
'Cannot find any Python version in "pyenv".')
72 log.info(
'Install a Python version 3.3+ into "pyenv".')
73
74 rc = 1
75 break
77 '*',
78 venv_capable=False,
79 as_paths=True
80 )
81 if len(vers) == 0:
82 log.error(
'Cannot find a Python version in "pyenv".')
83 log.info(
'Install a Python version 3.3+ into "pyenv".')
84
85 rc = 1
86 break
87 per = os.environ['PYENV_ROOT']
88
89 pyts = [
90 [tbl.HEADER, 'A', 'Venv-Capable', 'Version', '"pyenv" Location'],
91 [tbl.SEPARATOR]
92 ]
93 for ver in vers:
94 pyts_item = [
95 tbl.DATA,
98 os.path.basename(ver),
99 '%PYENV_ROOT%' + os.sep + ver[len(per):]
100 ]
101 pyts.append(pyts_item)
102
103 pyts.append([tbl.SEPARATOR])
104
105 pves = [
106 [tbl.HEADER, 'A', 'Version', 'Name', '"pyenv" Location'],
107 [tbl.SEPARATOR]
108 ]
109 for ver in vers:
111 for venv in venvs:
112 act = ' '
113 if (
114 ('PROMPT' in os.environ)
115 and
116 ('({})'.format(os.path.basename(venv)) in os.environ['PROMPT'])
117 ):
118 act = '*'
119 pves.append([
120 tbl.DATA,
121 act,
122 os.path.basename(ver),
123 os.path.basename(venv),
124 '%PYENV_ROOT%' + os.sep + venv[len(per):]
125 ])
126
127 pves.append([tbl.SEPARATOR])
128
130 pyts,
131 headline='INSTALLED PYTHON VERSIONS (A = active):'
132 )
133 table_pyts.run()
134
136 pves,
137 headline='AVAILABLE PYTHON VIRTUAL ENVIRONMENTS (A = active):'
138 )
139 table_pves.run()
140
143
144 break
145
146 except:
148 rc = 1
149 finally:
150 os.chdir(cwd)
151 return rc
152
153
154
155
int listProjectProperties(bool show_tree=False)
Display the table, which shows a list about project properties.
str getGlobalStar(str ver)
Get the "*" marker for this version, if it is the globally selected version in "pyenv".
list[str] getEnvs(str ver, str name=' *', bool as_paths=False)
Get list of installed virtual environments for a specific Python version in "pyenv".
list[str] getPythonVersions(str version=' *', bool venv_capable=False, bool as_paths=False)
Get list of installed Python version directories in "pyenv".
str getColoredVenvCapability(str ver)
Get the colored virtual environment capability str for the specific version number or path.
verbose((str, tuple) msg)
Log verbose message colored to console only.
info((str, tuple) msg)
Log info message colored to console only.
error((str, tuple) msg)
Log error message colored to console only.