[p4python] p4python: changes between dates does not give expected result
Sven Erik Knop
sknop at perforce.com
Fri Sep 17 06:03:09 PDT 2010
if you want to receive the exact same output in P4Python that you get
from P4, you need to disable the tagged output.
Tagged mode is used by default in P4Python. In tagged mode, the
information you receive from the server is pre-parsed and you will, as
you discovered, receive an array of dictionaries, with each dictionary
containing the values for a change.
The date returned is second after epoch, that is 1/1/1970 00:00:00. In
Python you can convert this to a proper date with the following command:
for desc in p4.run_changes( ... ):
date = datetime.utcfromtimestamp( int( desc[ "time" ] ) )
Alternatively, you can switch tagged mode off:
p4.tagged = False
result = p4.run_changes( ... ) # result is now an array of strings
identical to the strings shown from P4
For tagged mode, you can leave '-t' out of the parameter list, by the
way, it has no effect (but doesn't harm either).
By the way, to see tagged mode in action in P4, use the switch -Ztag:
p4 -Ztag changes -s submitted -u user ... at date1, at date2
Let me know if you need any additional information.
On 17/09/2010 13:47, Kostas Kevrekidis wrote:
> I am using python to parse perforce. I am trying to use the command:
> p4.run("changes","-l","-t","-ssubmitted","-u","user", "branch/...",
> "@" + date1 + ",@" + date2) , where date2 and date1 are variables and
> to receive a list of changes submitted between date1 and date2 of a
> specific user. I also would like to get a date format as described in
> the documentation:
> "If you use the -t option to display the time of each changelist, the
> format is:
> Change num on date hh:mm:ss by user at client [status] description"
> I don't getting the desired results _at all_. Instead I am receiving
> 1. A list of 101 items, where every item is a dictionary, that are
> of date > date1
> 2. The date is in the form 1209135617
> I suppose the parameters are not received very well. Although the "-l"
> parameter is recognized the rest are ignored or have to be provided in
> a different way than described in the documentation. The "--s" and
> "submitted" parameter and value for example have to be concatenated in
> order to be perceived correctly something that is not documented
> I tried many different combinations in providing parameters and
> changelist numbers.
> Can you please give me some information on this behavior? Is there
> maybe a work around?
> >>> print sys.version_info
> (2, 6, 5, 'final', 0)
> p4python mailing list
> p4python at perforce.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the p4python