Sunday, April 17, 2011

Modification in the Application code :- Python Byte-Code(.pyc)

Not amused but its a weird experience that the python byte-code(.pyc) which I generated on my system refused to work properly on other systems.Their is nothing wrong in it . When a python compiler generates the byte-code it optimizes the source-code suitable for further execution.However it is easy to take the byte-code in any platform and it'll work well.A Java programmer will think that once I've created the byte-code I can move the code anywhere and in any system and it'll work but this is not true with python byte-code(.pyc). (.pyc) is very different from (.class).Python byte-code is not compatible between python releases(eg:- Python2.x is not compatible with any of python-3.x release).Also, some of the modules like multiprocessing are not well supported in windows operating system , therefore a code or byte-code using these module will not work properly on windows operating system. This is one of the reason that it will also create problems while porting to other platforms.
However as some of the bugs are reported here is a quick solution to those.
  • Bug 1. IOError: [Errno 2] No such file or directory: '/home/sachin/LDM/a9c97fa678f4a067bccf15a8befb27358d72de8b7b202693ed1d174c/Uinfo' .Submitted by Arihant (Sachin).
  • Bug 2. ZeroDivisionError: integer division or modulo by zero .Submitted by blunderboy & pankajbankanitjsr.

Now the solution.
  • As per the Bug 1 is concerned.I didn't really get it. This part of code is working well. This code has been checked on Fedora , Ubuntu & Mandriva.It is working very well.However if you still having problem create "a9c97fa678f4a067bccf15a8befb27358d72de8b7b202693ed1d174c" folder at the installation directory inside LDM folder.Also create a Uinfo file in this newly created folder.

  • Now on the report of Bug 2 problem was traced back to TabWidget.py.Download TabWidget.py from here.In this file go to line number 148 and replace self.setCellWidget(row,2,self.getLabel(str((100*dL)/int(obj.length))+'%',str(100*dL/int(obj.length)))) line with

    if int(obj.length) == 0 :
      self.setCellWidget(row,2,self.getLabel(str(0)+'%',str(0)))
    else :
     self.setCellWidget(row,2,self.getLabel(str((100*dL)/int(obj.length))+'%',str(100*dL/int(obj.length))))


    Remember Indentation matters in python.So , do proper indentation while updation.Now after you have updated the code , replace the TabWidget.pyc in your LDM installation with TabWidget.py.
    Note :- If you get the updated code at line-148 of TabWidget.py that means it has already been updated.So , put it in place of TabWidget.pyc and it'll work.
One important thing is that many people keep on asking the installation procedure for LDM.To them

READ INSTRUCTIONS IN INSTALL.TXT & README OF DOWNLOAD

Thank you all for posting bugs.Keep posting bugs as soon as you get it.