#!/usr/bin/python # # Client Workspace Checker # # Start easy : list all workspaces with name | age | # have entries | # open files # # This script resets the access date to now and therefore can only be used once !!! import P4 from datetime import datetime class ClientInfo: def __init__( self, name, age, have, opened): self.name = name self.age = age self.have = have self.opened = opened def __str__( self ): return "%s | %s days | %s have | %s opened" % ( self.name, self.age, self.have, self.opened ) class ClientChecker: def __init__( self ): self.p4 = P4.P4() self.p4.connect() self.clients = [] def run( self ): for client in self.p4.run_clients(): name = client['client'] lastAccess = datetime.utcfromtimestamp( int(client['Access']) ) age = datetime.now() - lastAccess have = self.getNumberHaveEntries( name ) opened = self.getNumberOpened( name ) self.clients.append( ClientInfo( name, age.days, have, opened ) ) def getNumberHaveEntries( self, client ): try: sizes = self.p4.run_sizes( "-s", "//...@%s" % client) return int( sizes[0][ 'fileCount' ] ) except P4.P4Exception, err: print err return 0 def getNumberOpened( self, client ): opened = self.p4.run_opened( "-C", client ) return len( opened ) def report( self ): for info in self.clients: print info if __name__ == "__main__": info = ClientChecker() info.run() info.report()
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 8219 | Sven Erik Knop | Update to Python 2.7 | ||
#3 | 7372 | Sven Erik Knop |
Rollback Rename/move file(s). To folder "perforce" is needed. |
||
#2 | 7370 | Sven Erik Knop | Rename/move file(s) again - this time to the right location inside a perforce directory. | ||
#1 | 7368 | Sven Erik Knop | Moved scripts to new P4Python lib directory. | ||
//guest/sven_erik_knop/perforce/P4Pythonlib/scripts/ClientChecker.py | |||||
#1 | 7370 | Sven Erik Knop | Rename/move file(s) again - this time to the right location inside a perforce directory. | ||
# | Change | User | Description | Committed | |
#1 | 7368 | Sven Erik Knop | Moved scripts to new P4Python lib directory. | ||
//guest/sven_erik_knop/scripts/ClientChecker.py | |||||
#1 | 7271 | Sven Erik Knop |
Added ClientChecker.py. A little script that inquires the server on all client workspaces and prints out list with the age of each workpace as well as the size of each workspace. This is done via "p4 sizes", which has the nice side effect of not updating the access timestamp on the workspace. Needs P4Python 2007.3 to run. |