Jump to content

P4Python: Problem with P4.Progress

p4python python api

  • Please log in to reply
3 replies to this topic

#1 etcher



  • Members
  • Pip
  • 1 posts

Posted 11 July 2016 - 12:58 PM

Hello everybody!
Please help me with following problem. I need to implement progress bar for huge sync operation in my app.
And I cannot figure out how P4.Progress is working.

Here is my small test code.

import P4

P4PORT = 'port:1666'
P4USER = 'user'
P4CLIENT = 'client'

p4 = None

class MyProgress(P4.Progress):
	TYPES = ["Unknown", "Submit", "Sync", "Clone"]
	UNITS = ["Unknown", "Percent", "Files", "KBytes", "MBytes"]
	def __init__(self):
	def init(self, typ):
		P4.Progress.init(self, typ)
		print "Progress.init with '%s'" % self.TYPES[typ]
	def setDescription(self, description, units):
		P4.Progress.setDescription(self, description, units)
		print "Progress.setDescription with '%s' and units '%s'" % (description, self.UNITS[units])
	def setTotal(self, total):
		P4.Progress.setTotal(self, total)
		print "Progress.setTotal with '%s' " % total
	def update(self, position):
		P4.Progress.update(self, position)
		print "Progress.update with '%s'" % position
	def done(self, fail):
		P4.Progress.done(self, fail)
		print "Progress.done with '%s"'' % fail

def init(p4Port, p4User, p4Client):
	global p4
	p4 = P4.P4()
	p4.port = p4Port
	p4.user = p4User
	p4.client = p4Client
	p4.charset = 'utf8'
	p4.exception_level = 1
	p4.progress = createProgress()

def createProgress():
	progress = MyProgress()
	progress.setDescription('My Description', progress.UNIT_KBYTES)
	return progress

def run():

if __name__ == '__main__':

How the progress work? it should call update method with each of progress step?
In my code update is never called.
What am I doing wrong?

#2 leocov



  • Members
  • Pip
  • 2 posts

Posted 25 January 2018 - 06:23 PM

Many years later . . .
I am having the same problem, did you ever get this resolved?

#3 Sambwise


    Advanced Member

  • Members
  • PipPipPip
  • 1148 posts

Posted 26 January 2018 - 03:49 PM

What's the output from the run_sync() call, and which if any of the MyProgress methods get called?

#4 leocov



  • Members
  • Pip
  • 2 posts

Posted 26 January 2018 - 10:21 PM

I figured this out, when you call p4.run_sync() as in the original example you need to call it with the "-q" / quiet param to get progress messages back from the server.

Also tagged with one or more of these keywords: p4python, python, api

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users