From pykde Wed Aug 02 16:18:31 2006 From: Paul Waldo Date: Wed, 02 Aug 2006 16:18:31 +0000 To: pykde Subject: Re: [PyKDE] Odd behavior from KFileItem Message-Id: <200608021218.31975.pwaldo () waldoware ! com> X-MARC-Message: https://marc.info/?l=pykde&m=115453566022155 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_XBN0EjSNg9kX6LB" --Boundary-00=_XBN0EjSNg9kX6LB Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Jim, I know its been a while since we talked about this issue. I put together a quickie test harness to illustrate the file size issue. Hopefully that will help. Thanks for any help you can provide! Paul On Thursday 20 July 2006 2:58 pm, Jim Bublitz wrote: > On Thursday 20 July 2006 10:41, Paul Waldo wrote: > > Hi all, > > > > I'm seeing some odd behavior from KFileItem. I use KIO.listRecursive to > > get files: > > def locateFiles(self, url): > > self.kurl = KURL(url) > > job = KIO.listRecursive(self.kurl, False) > > QObject.connect(job, SIGNAL("entries(KIO::Job*, const > > KIO::UDSEntryList&)"), self.newItems) > > > > For each of the found files, I create a KFileItem: > > def newItems(self, job, list): > > newFiles = [] > > for udsList in list: > > f = KFileItem(udsList, self.kurl, False, True) > > newFiles.append(f) > > self.files.append(f) > > > > Later on, I display the data for each of the found files: > > class FileItem: > > def __init__(self, destDirBase, template, kFileItem, parent): > > self._kFileItem = kFileItem > > self.size = str(self._kFileItem.size()) > > if self.size == None: > > self.size = "Unknown" > > self.time = self._kFileItem.timeString() > > > > The size always ends up as None. I've pulled apart the UDSEntryList and > > the size appears to be correct there. Somehow KFileItem is not storing > > it. > > The only problem I can see that PyKDE could introduce is an incorrect > conversion from KIO.filesize_t to Python long. I'm pretty sure that works > correctly, but will check it again. I don't see anywhere else PyKDE could > introduce a problem. > > > Also, the KFileItem::timeString is off; for example, "ls" reports the > > time correctly as "Jul 20 11:03", while the timeString reports > > "2006-07-20 3:03 pm". Is this a locale issue? My "date" command is > > showing this: "Thu Jul 20 13:38:44 EDT 2006". > > Looks like an EDT vs GMT issue? > > > I'm running PyKde3 and python 2.4.3. > > > > > > Any light you could shed on either of these issues would be greatly > > appreciated! > > > > Paul > > > > _______________________________________________ > > PyKDE mailing list PyKDE@mats.imk.fraunhofer.de > > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde --Boundary-00=_XBN0EjSNg9kX6LB Content-Type: application/x-python; name="locate_test.py" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="locate_test.py" from qt import * from kdecore import * from kdeui import * from kio import * import sys description = "A KDE Application" version = "0.1"; class KdeApp(KMainWindow): def __init__(self): KMainWindow.__init__(self,None,"KdeApp") def locateFiles(self, url): self.files = [] self.url = KShell.tildeExpand(url) self.kurl = KURL(self.url) job = KIO.listRecursive(self.kurl, True) print 'locating files in ' + str(self.kurl.pathOrURL()) QObject.connect(job, SIGNAL("entries(KIO::Job*, const KIO::UDSEntryList&)"), self.newItems) QObject.connect(job, SIGNAL("result(KIO::Job *)"), self.result) def newItems(self, job, list): for udsList in list: f = KFileItem(udsList, self.kurl, False, True) for l in udsList: if l.m_uds == KIO.UDS_SIZE: # # This is the correct size of the file # print 'size is ' + str(l.m_long) self.files.append(f) def result(self, job): print "Result obtained" if job.error() != 0: print "Error: " + str(job.errorString()) job.showErrorDialog(self) for file in self.files: (kurl, local) = file.mostLocalURL() # # This will incorrectly show the file size as None! # print "result: " + str(kurl.prettyURL()) + ' size is ' + str(file.size()) def main(): global kapp,version,description,options options = [ ("+[Dir]", "dir to open", "") ] aboutdata = KAboutData("test", "test", version, description, \ KAboutData.License_GPL, "(C) 2005 AUTHOR", None, None, "your@email.com") aboutdata.addAuthor("AUTHOR", None, "your@email.com") KCmdLineArgs.init(sys.argv,aboutdata) KCmdLineArgs.addCmdLineOptions(options) kapp = KApplication() args = KCmdLineArgs.parsedArgs() widget = KdeApp() widget.show() for i in range(args.count()): widget.locateFiles(args.arg(i)) return kapp.exec_loop() if __name__ == '__main__': main() --Boundary-00=_XBN0EjSNg9kX6LB Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ PyKDE mailing list PyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde --Boundary-00=_XBN0EjSNg9kX6LB--