Package perforce :: Module objects :: Class Counter
[frames] | no frames]

Class Counter



object --+
         |
        Counter

A named Perforce counter value.

A Perforce counter is a named integer value stored on the Perforce server. Counters that haven't previously been set all have an initial value of zero.

Reading the value of a counter requires 'list' permissions. Modifying the value of a counter requires 'review' permissions. Modifying a protected counter requires 'super' permissions.


Warning: Counter value manipulation does not support atomic operations and so it is recommended that only a single process attempts to modify a particular counter.

Instance Methods
 
__init__(self, connection, name)
Construct a named counter object.
int
getValue(self)
Retrieve the current value of the counter.
 
setValue(self, value, force=False)
Set a new value for the counter.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties
str or unicode name
The name of the counter.

Inherited from object: __class__

Method Details

__init__(self, connection, name)
(Constructor)

 
Construct a named counter object.
Parameters:
Overrides: object.__init__

getValue(self)

 
Retrieve the current value of the counter.
Returns: int
The value of the counter.

Note: Requires 'list' access permissions.

setValue(self, value, force=False)

 
Set a new value for the counter.
Parameters:
  • value (str, unicode or int) - The new value to set the counter to.
  • force (boolean) - If True, force setting of a protected Perforce counter such as 'job', 'change' or 'security'. Otherwise an error will be raised. Requires 'super' access permissions.
Raises:
  • CommandError - If the counter could not be set. eg. due to insufficient permissions.

Note: Requires 'review' access permissions.


Property Details

name

The name of the counter.
Get Method:
unreachable.name(self) - The name of the counter.
Type:
str or unicode