#!/p4/common/python/bin/python3 import os import sys import re from P4 import P4, P4Exception P4PORT = os.getenv ('P4PORT', 'UNDEFINED_P4PORT_VALUE') P4USER = os.getenv ('P4USER', 'UNDEFINED_P4USER_VALUE') P4CLIENT = 'DTClient' P4CONFIG = os.getenv ('P4CONFIG', 'UNDEFINED_P4CONFIG_VALUE') P4BIN = os.getenv("P4BIN", "p4") class Main: def initP4(self): self.p4 = P4() self.p4.prog = 'a.py' self.p4.version = '1.0' self.p4.port = P4PORT self.p4.user = P4USER self.p4.client = P4CLIENT self.p4.ticket_file = os.getenv ('P4TICKETS', '/p4/1/.p4tickets') # Ensure this matches the P4Python version used. # API Level 79 is for p4d 2015.2. self.p4.api_level = 79 self.stream = None self.streamDepot = None self.streamDepth = None self.streamShortName = None try: self.p4.connect() except P4Exception: print ("Unable to connect to Perforce at P4PORT=%s.\n\nThe error from the Perforce server is:" % P4PORT) for e in self.p4.errors: print (e) for w in self.p4.warnings: print (w) return False try: print ("Doing 'p4 login -s' login status check.") self.p4.run_login('-s') except P4Exception: userMessage = "Your attempt to submit changelist %s has been rejected because the CBD system user [%s] is not logged into the server [P4PORT=%s]. Please contact your Perforce Administrator for help.\n\nThe error from the Perforce server is:\n" % (self.myOptions.changelist, P4USER, P4PORT) print (userMessage) for e in self.p4.errors: print (e) for w in self.p4.warnings: print (w) return False return True def run_tests(self): print ("==============================================================================") for depot in ('pb', 'jam', 'DeepThought'): dData = self.p4.fetch_depot(depot) self.streamDepot = depot # print (dData) if (dData['StreamDepth']): self.streamDepth=re.sub ('^.*/', '', dData['StreamDepth']) self.streamDepth=int(self.streamDepth) else: self.streamDepth=1 print ("Depot %s depth is %s.\n" % (self.streamDepot,self.streamDepth)) if (self.streamDepth > 1): file = '//%s/LevelTwo/MAIN/DeepThought.cbdsst' % self.streamDepot else: file = '//%s/main/%s.cbdsst' % (self.streamDepot, self.streamDepot) print ("Looking at file: %s" % file) pathElements = file.split('/') #print ("PE=%s" % pathElements) self.streamShortName = pathElements[self.streamDepth+2] self.stream = '//%s/%s' % (self.streamDepot, pathElements[3]) i = 1 while (i < self.streamDepth): #print ("I=%s. Before: %s" % (i, self.stream)) self.stream = "%s/%s" % (self.stream, pathElements[i+3]) #print ("I=%s. After: %s" % (i, self.stream)) i =i +1 print ("D=[%s] SN=[%s] S=[%s]" % (self.streamDepot, self.streamShortName, self.stream)) print ("------------------------------------------------------------------------------") return True if __name__ == '__main__': """ Main Program """ main = Main(*sys.argv[1:]) if (not Main.initP4(main)): sys.exit (1) print ("Ready.") if (Main.run_tests(main)): sys.exit (0) else: sys.exit (1)
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 21706 | Sven Erik Knop |
Populate //cbd/main/... .... |