Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ess-python-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESS Beam Physics
ess-python-tools
Commits
e22140d4
Commit
e22140d4
authored
10 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
added installed module (helper)
parent
f21f1be6
No related branches found
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ess/__init__.py
+1
-0
1 addition, 0 deletions
ess/__init__.py
ess/installed.py
+30
-0
30 additions, 0 deletions
ess/installed.py
with
31 additions
and
0 deletions
ess/__init__.py
+
1
−
0
View file @
e22140d4
import
TraceWin
import
installed
This diff is collapsed.
Click to expand it.
ess/installed.py
0 → 100644
+
30
−
0
View file @
e22140d4
def
get_installed_packages
():
'''
Returns a dictionary of installed packages
Example usage:
(print all packages):
for package in get_installed_packages():
print package
'''
import
pip
installed_packages
=
pip
.
get_installed_distributions
()
installed_packages_list
=
sorted
([
"
%s==%s
"
%
(
i
.
key
,
i
.
version
)
for
i
in
installed_packages
])
return
installed_packages
def
is_package_installed
(
name
):
'''
Returns a bool, true if package name
was found in one of the string representations
of any package.
case insensitive (meaning Package==package)
'''
name
=
name
.
lower
()
ret
=
False
for
package
in
get_installed_packages
():
if
name
in
str
(
package
).
lower
():
print
"
Found
"
,
package
ret
=
True
return
ret
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment