Package perforce :: Module api :: Class Enviro
[frames] | no frames]

Class Enviro



object --+
         |
        Enviro

A Perforce Enviro object.

Environment keys and values use unicode strings if the platform supports them (currently only NT), otherwise they use str strings.

Arguments will be coerced to the correct type using the default codec.

The constructor takes an optional 'service' parameter that allows you to specify the service-specific registry settings to use. Set this parameter to a str or unicode to get/set the settings for that service. Set this parameter to None to get/set the settings for the machine.

For example:
 | e = Enviro('my-service') # Manipulate settings for my-service
 | e = Enviro(None)         # Manipulate settings for machine
 | e = Enviro()             # Maniuplate settings for current user



Note: The 'service' parameter is only supported on NT.

Nested Classes
  ItemType
Enumeration of perforce.api.Enviro item types.
Instance Methods
 
__new__(T, S, ...)
Returns: a new object with type S, a subtype of T
 
config(cwd)
Search for a P4CONFIG file in the specified directory and, if found, update the Enviro with the values found there.
 
get(key)
Returns: str or unicode
 
getConfig()
Returns: str or unicode
 
getType(key)
Returns: Enviro.ItemType
 
reload()
Reload values from the Windows registry.
 
set(key, value)
Sets the value of a variable in the Windows registry.
 
update(key, value)
Updates the value of a variable in this Enviro instance.

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

Properties

Inherited from object: __class__

Method Details

__new__(T, S, ...)

 
Returns:
a new object with type S, a subtype of T

Overrides: object.__new__

config(cwd)

 

Search for a P4CONFIG file in the specified directory and, if found, update the Enviro with the values found there.

Use getConfig afterwards to query the path of the P4CONFIG file loaded.
Parameters:
  • cwd (str or unicode) - The directory to search for P4CONFIG files.
Returns:
None

See Also: getConfig

get(key)

 
Parameters:
  • key (str or unicode) - The Perforce environment variable to lookup. eg. 'P4PORT', 'P4CONFIG', 'P4CLIENT' etc.
Returns:
str or unicode

Note: Platforms that support Unicode environments will return unicode strings.

See Also: getType

getConfig()

 
Returns:
str or unicode

See Also: config

getType(key)

 
Parameters:
  • key (str or unicode) - The Perforce environment variable to lookup.
Returns:
Enviro.ItemType

reload()

 
Reload values from the Windows registry.
Returns:
None

set(key, value)

 

Sets the value of a variable in the Windows registry.

Which registry location will be dependent on how the Enviro was constructed (machine-wide, user-specific or service-specific).
Parameters:
  • key (str or unicode) - Name of the variable to set. eg. 'P4PORT' or 'P4CLIENT'
  • value (str or unicode) - The value to set the variable to.
Returns:
None

Raises:
  • OSError - If the variable could not be set in the Windows registry.

update(key, value)

 
Updates the value of a variable in this Enviro instance.
Parameters:
  • key (str) - Name of the variable to update. eg 'P4PORT' or 'P4CLIENT'
  • value (str) - Value to set the variable to.
Returns:
None