Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

CLUES Python utils - Utils and General classes that spin off from CLUES

Project description

# CLUES Python Utils
This is a set of util functions and classes for python that were initially created in the CLUES project, but are of general purpose and can be used in other projects, such as VMCA.

These utilities include a mechanism to easily load configuration files, to connect to OpenNebula, to generate objects from a XML document, etc.

## Examples

### eventloop module

It is possible to create a eventloop in which the events are automatically called as they happen in the time. This is a simple example of an event loop with periodical events and one eventual alarm.

def function(param):
print param

import cpyutils.eventloop
cpyutils.eventloop.get_eventloop().add_periodical_event(1, 0,"period-check",function, ["sisisi"])

This eventloop has also the possibility of running in real time or in simmulated time (the internal time of the event loop advances as a time machine to the next event).

### config module

Using this piece of code you will have the initialized values of these variables in the ```myconfig``` object, or the values in the configuration file (more complex constructions are available).

import cpyutils.config
cpyutils.config.set_paths([ './etc/', '/etc/' ])
myconfig = cpyutils.config.Configuration(
"DEBUG_LEVEL": "error",
"LOG_FILE": None,
### parameters module

It offers an easy mechanism to parse a commandline and to generate the help for a CLI. The next code will be a version for the ```ls``` command line utility.

ap = CmdLineParser("ls", "List directory contents", [
Flag("-a", "--all", desc = "do not ignore entries starting with ."),
Flag("-A", "--almost-all", desc = "do not list implied . and .."),
Flag("--author", desc = "with -l, print the author of each file"),
Flag("-b", "--escape", desc = "print C-style escapes for nongraphic characters"),
Parameter("--block-size", desc = "scale sizes by SIZE before printing them. E.g., '--block-size=M' prints sizes in units of 1,048,576 bytes. See SIZE format."),
Argument("FILE", "the files that want to be listed", count = -1)

print ap

# Installing

Installing cpyutils package is as easy as executing (as root):

``` $ python install --record installed-files.txt```

This way you will have the installed-files.txt file to be able to uninstall this package in case that you don't need it anymore. To uninstall this package, you can execute (as root):

``` $ cat installed-files.txt | xargs rm -rf```

Project details

Release history Release notifications

History Node


History Node


History Node


History Node


History Node


History Node


History Node


This version
History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
cpyutils-0.14.tar.gz (40.4 kB) Copy SHA256 hash SHA256 Source None Dec 15, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page