###################################################################### # Copyright (c)2011-2012, 2015, David L. Armstrong. # Copyright (c)2012, Cisco Systems, Inc. # # P4OO.Client.py # # See COPYRIGHT AND LICENSE section in pod text below for usage # and distribution rights. # ###################################################################### #NAME / DESCRIPTION ''' Perforce Client object P4OO.Client provides standard P4OO._SpecObj behaviors Spec Attributes: client description owner host root altroots options submitoptions lineend view datetime Attributes: update access Query Options: user: type: [ string, P4OOUser ] multiplicity: 1 owner: (interchangeable with user) namefilter: type: [ string ] multiplicity: 1 max: type: [ integer ] multiplicity: 1 ''' ###################################################################### # Includes # from P4OO.Change import P4OOChangeSet from P4OO._Base import _P4Warning, _P4Fatal ###################################################################### # P4Python Class Initialization # from P4OO._SpecObj import _P4OOSpecObj class P4OOClient(_P4OOSpecObj): # Subclasses must define SPECOBJ_TYPE _SPECOBJ_TYPE = 'client' ###################################################################### # Globals # # # Subclasses must define SPECOBJ_TYPE # sub SPECOBJ_TYPE { return( 'client' ); } ###################################################################### # Methods # def getChanges(self, status=None): ''' Find all changes this client "has" sync'd ''' # Asking a Client for its changes is implemented as querying Changes filtered by Client return(self.query(P4OOChangeSet, client=self, status=status)) def getLatestChange(self): ''' find the latest change this client "has" ''' # Asking a Client for its latest change is just querying the first change record. Nifty. p4Changes = self.query(P4OOChangeSet, files="#have", max=1, client=self) # We only expect one result, we only return one result. return(p4Changes[0]) def getOpenedFiles(self, user=None): ''' Return a P4OOFileSet of files opened in this client. ''' return(self._runCommand('opened', user=user, client=self)) def sync(self, *fileSpec, **kwargs): ''' Sync the client (p4 sync) using the optional supplied fileSpec(s) ''' p4Output = None try: p4Output = self._runCommand('sync', p4client=self, files=fileSpec, **kwargs) except _P4Warning as e: import re if re.search("\nWARNING: File\(s\) up-to-date\.$", str(e)): pass else: raise(e) return(p4Output) def reopenFiles(self): self._delSpecAttr('host') self.saveSpec() try: return self._runCommand('reopen', files="//%s/..." % self._getSpecID(), p4client=self) except _P4Warning: return True def revertOpenedFiles(self): self.reopenFiles() try: return self._runCommand('revert', noclientrefresh=True, files="//%s/..." % self._getSpecID(), p4client=self) except _P4Warning: return True def deleteWithVengeance(self): try: self.deleteSpec(force=True) except _P4Fatal: # First, simplify things by removing any Host spec attr for this client self._delSpecAttr('host') self.saveSpec() # Next try removing pending changes, then try spec again changes = self.getChanges(status="pending") for change in changes: change.deleteWithVengeance() self.deleteSpec(force=True) return True from P4OO._Set import _P4OOSet class P4OOClientSet(_P4OOSet): ''' P4OOClientSet currently implements no custom logic of its own. ''' # Subclasses must define SETOBJ_TYPE _SETOBJ_TYPE = 'clients' ###################################################################### # Standard authorship and copyright for documentation # # AUTHOR # # David L. Armstrong <armstd@cpan.org> # # COPYRIGHT AND LICENSE # # Copyright (c)2011-2012, 2015, David L. Armstrong. # Copyright (c)2012, Cisco Systems, Inc. # # This module is distributed under the terms of the Artistic License # 2.0. For more details, see the full text of the license in the file # LICENSE. # # SUPPORT AND WARRANTY # # This program is distributed in the hope that it will be # useful, but it is provided "as is" and without any expressed # or implied warranties. #
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 11427 | david_armstrong |
More HOWTO.html content Adding user option to P4OOClient.getOpenedFiles() for reciprocity with P4OOUser.listOpenedFiles() |
||
#2 | 11413 | david_armstrong |
1. Started HOWTO.html document intended to become a complete reference and HowTo guide for P4OO.py. Saving progress. 2. Added attribute and querying specifications to each Spec module's documentation. 3. updated p4Config.yml to allow for more consistency between "user" and "owner" attribute names for some spec object queries. |
||
#1 | 11390 | david_armstrong | First submit to Perforce Workshop |