[p4python] RE: Odd behavior on save

Wright, Richard richardw at cobaltgroup.com
Thu Sep 8 15:48:39 PDT 2005


Thanks, that's good to know.
 
I don't really mind calling the '-o' before the '-i', but I agree that it
would be useful if it was better documented somewhere.  (I was scratching my
head trying to figure out why the save method would work sometimes and not
at other times, and the places I was using it didn't make the pattern
obvious.)
 
I don't know how p4ruby does the spec -o behind the scenes, but here is a
little wrinkle that I ran into to keep in mind for the documentation or a
future implementation:
For clients and groups, you can easily do a "<spec> -o dummy" but for users,
you can run into an issue if you are currently using all of your licenses.
In that case you have to pass a current username to the "user -o".
 
-Rick

-----Original Message-----
From: Robert Cowham [mailto:robert at vaccaperna.co.uk]
Sent: Thursday, September 08, 2005 3:34 PM
To: 'Wright, Richard'; p4python at perforce.com
Subject: RE: [p4python] RE: Odd behavior on save


This is a current feature of the API! You must do a "<spec> -o" (fetch_XXX)
before doing a "<spec> -i" (save_XXX) command.
 
Behind the scenes, when you do a save of a spec form, there is a Perforce
API call to parse the hash using a spec definition which is stored from the
previous spec -o call (and currently overwritten by any other spec -o call).
 
On my list to do is to implement the same as p4ruby which does a spec -o
behind the scenes if it doesn't have one already, and caches for future use.
For now, it should be better documented...
 
Robert 


  _____  

From: p4python-bounces at perforce.com [mailto:p4python-bounces at perforce.com]
On Behalf Of Wright, Richard
Sent: 08 September 2005 10:57
To: 'p4python at perforce.com'
Subject: [p4python] RE: Odd behavior on save


Here is some additional info:
The fetch can fetch any client name and the save of the other client will
still work.   So, these work:
p4c.fetch_client('unknown_client')
p4c.run_client('-o', 'unknown_client')
p4c.run('client', '-o', 'unknown_client')
 
Interestingly, if I use:
p4c.fetch_user('unknown_user')
I get the same "Missing 'Client'" error on the save.  
 
However, if I use:
p4c.fetch_group('unknown_group')
I get the following error on the call to save_client:
 
P4Error: Error in client specification.
Error detected at line 1.
Unknown field name 'Subgroups'.
 
So somehow, calls to fetch are affecting calls to save, but I don't know
what is going on in the background.
 
-Rick

-----Original Message-----
From: Wright, Richard 
Sent: Thursday, September 08, 2005 1:19 PM
To: 'p4python at perforce.com'
Subject: Odd behavior on save


I have spent some time narrowing down this problem to the minimum that I can
come up with to recreate it, and I want to see if anyone else out there can
reproduce it.
 
Take the following code:
import p4

p4c = p4.P4()
p4c.parse_forms()
p4c.connect()
 
updateclient = {'Client' : 'richardw_client_test',
                'Description' : 'This is a test',
                'Host' : 'SEA-RICHARDW2',
                'Update' : '2005/09/09 11:25:35',
                'Access' : '2005/09/09 11:23:32',
                'Owner' : 'richardw',
                'LineEnd' : 'local',
                'Root' : r'c:\Documents and Settings\richardw',
                'Options' : 'noallwrite noclobber nocompress unlocked
nomodtime normdir',
                'View' : ['//Tools/... //richardw_client_test/Tools/...',
                          '//Specs/... //richardw_client_test/Specs/...']}
 
#p4c.fetch_client('richardw_client_test')
print p4c.save_client(updateclient)
p4c.disconnect()


The code as above gives me the following error:
P4Error: Error in client specification.
Missing required field 'Client'.

However, if I uncomment the "fetch" line, it works.  Note that I am not
saving the results of the fetch method to anything, simply running it.  I
still pass the "updateclient" dictionary to the "save" method.  Any thoughts
about what may change when the fetch method is run?
 
For the record, this is on Windows 2000, Python 2.4, and p4Python 0.6 (and
the API included in that package), connecting to a 2005.1 Perforce server.
Also note that the 'richardw_client_test' client is not new but was
originally created with P4V.

Rick Wright
CM/Build Engineer
The Cobalt Group, Inc.
2200 First Avenue South
Seattle, WA 98134
richardw at cobaltgroup.com <mailto:richardw at cobaltgroup.com> 
www.cobaltgroup.com 

p. 206.219.8382

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.perforce.com/pipermail/p4python/attachments/20050908/7ea5cf69/attachment-0001.html>


More information about the p4python mailing list