[p4] Python code issue with triggers

Dix, John JDix at MedManageSystems.com
Fri Sep 21 09:07:52 PDT 2007


Hello all,



I have written some python code for a trigger:

            CheckDesc form-in change "C:\Python25\python.exe
C:\PerforceScripts\CheckDescription.py %formfile%"

 

And my code executes until it hits this line:

            if k[:4] == 'User':

in GetUserList().

 

When I execute this in the debugger or on its own I get the list of
users, but it fails when called in the trigger. Any ideas?

 

def GetUserList():

    result = {}

    Users = []

    objCmdFile = None

    try:

        objCmdFile = os.popen("p4 -G group -o dev", 'r')

    except IOError, e:

        print "Unable to open %s" % (objCmdFile, e)

    try:

        result = marshal.load(objCmdFile)

    except EOFError, e:

        print "Failed the marshal.load by EOFError"

    except ValueError, e:

        print "Failed the marshal.load by ValueError"

    except TypeError, e:

        print "Failed the marshal.load by TypeError"

    else:

        job_users = []

        for k in result.keys():

            if k[:4] == 'User': # user key format: User0, User1, ...

                u = result[k]

                print "%s" % u

                job_users.append(u)                 

    return Users

 

def main():

    UserList = []

    UserList = GetUserList()

    sys.exit(1)

    return retVal



More information about the perforce-user mailing list