Last page update: October 10, 2011
Available functionality:
- ProgressBar, a class to draw text-based progressbars.
- AutoDiscovery, a class to auto-detect current instance, site, package and project from GENROPY_xxx environment variables and/or the current working directory.
It is a tool to gather information about projects, instances, sites, packages and commands available in a given GenroPy installation.
It tries to guess the current project, instance, site and package based on the current working directory.
Try to guess the current project, package, site and instance.
Environment variables:
The name of the current project.
The name of the current instance.
The name of the current site.
The name of the current package.
We apply these rules:
- look in the environment for a GENROPY_PROJECT, GENROPY_SITE, GENROPY_INSTANCE and GENROPY_PACKAGE variables. If anyone is present, we cross-check if they point to the right places. For doing this, we look to the declared places in the configuration (.gnr/environment.xml) and complain if they don’t.
- if GENROPY_PROJECT is missing, we look if the current path is inside one of the declared projects in the configuration. If we find one, we assume that it is the current project. If no, we don’t have a current project.
- if GENROPY_INSTANCE is missing, we look if the current path is inside one of the instances of the current project or if we are inside one of the declared instances in the configuration. If yes, we assume that is the current instance. If no, we don’t have a current instance.
- if GENROPY_SITE is missing... (same as the previous steps)
- if GENROPY_PACKAGE is missing... (same as the previous steps)
- If we have a project, but we don’t have an instance/site/package -and- the project has only one instance/site/package, then we assume that’s the current one.
Attributes:
the current project, if found
the current package, if found
the current instance, if found
the current site, if found
all packages in the current project, if a project has been found
all instances in the current project, if a project has been found
all sites in the current project, if a project has been found
all commands in the current project, if a project has been found
all projects in this GenroPy installation
all instances in this GenroPy installation
all packages in this GenroPy installation
all sites in this GenroPy installation
all commands in this GenroPy installation
path to the configuration file (e.g. ~/gnr/environment.xml)
AutoDiscovery‘s attributes contain instances of this class and its subclasses.
They have the following public attributes:
the name of this item
the absolute path to this item
Project have these additional methods:
all commands in this project
all instances in this project
all packages in this project
all sites in this project
Print a summary of what AutoDiscovery class found
| Parameters: | all – if False, print only the current project, instance, packages and site. if True, print a full report including all available items in this GenroPy installation |
|---|
Expand user home directory (~) and environment variables. Return the expanded path
| Parameters: |
|
|---|
Provides a text-based progress bar.
Example:
import time
with ProgressBar('ProgressBar test') as pg:
for n in xrange(333):
time.sleep(0.01)
pg.update(n/3.33)
if n > 233:
raise Exception, "Something bad happened."
Draws the progress bar.
Here’s how it looks:
Label padded to length [**********----------------------] 45.12% (3m 28s passed, 4m 54s remaining)