iewin.IEHtmlWindow shutil.move conflict

Discussion in 'Python' started by Todd7, Dec 7, 2005.

  1. Todd7

    Todd7 Guest

    I am writing a python program to load a pdf file into an IEHtmlWindow
    which displays it through adobe acrobat reader 7. Depending on the
    buttons the user clicks, the program moves it to another subdirectory
    with a new name. I am using python 2.4 with wxpython 2.6 on a windowsxp
    machine.

    I encounter a permission denied error when trying to move the file. It
    appears to be caused due to the loading of the pdf file into the
    IEHtmlWindow. The program is too long to post here, but below are some
    snippets of the code.

    self.PDFPanel = iewin.IEHtmlWindow(self, -1, style =
    wx.NO_FULL_REPAINT_ON_RESIZE)
    ....
    fileName = 'C:\\test.pdf'

    self.PDFPanel.LoadUrl(fileName)

    ....
    # if I do this: self.PDFPanel.Destroy()
    # then the following shutil.move works
    # else I get a [Errno 13] Permission denied: 'C:\\test.pdf'
    # tried loading another pdf file before doing shutil.move
    # like: self.PDFPanel.LoadUrl(C:\\Temp.pdf) which loaded fine, but
    # I still got a permission denied error

    shutil.move(fileName, 'C:\\NewName.pdf')


    As stated in the comments above, if I destroy the IEHtmlWindow, then the
    move works fine. I do not want to destroy it because I want to continue
    using it to load the next pdf file to work on renaming. I tried
    self.PDFPanel.LoadUrl('about:blank') before the shutil.move command.
    The window displayed a blank screen, but still the permission denied
    error. I then tried loading a different pdf file into the window, then
    doing the shutil.move on the first pdf, but still the permission denied
    error. If I destroy the window before the shutil.move command, then it
    works fine, but I need the IEHtmlWindow for other work.

    Any suggestions on how to get the IEHtmlWindow to let go of the pdf file
    before the shutil.move command without destroying the IEHtmlWindow all
    together?

    Thanks,
    Todd.
     
    Todd7, Dec 7, 2005
    #1
    1. Advertising

  2. Todd7

    Todd7 Guest

    Update:
    I have found that if I delay the time between when I load a new url into
    IEHtmlWindow and then do the shutil.move it works fine. Such as:

    self.PDFPanel.Navigate('about:blank') #Must empty pdf frame so file is
    not locked
    Temp_dlg = wx.MessageDialog(self, 'Waiting for delay',
    'Time delay',
    wx.OK | wx.ICON_INFORMATION
    )
    Temp_dlg.ShowModal()
    Temp_dlg.Destroy()
    shutil.move(fileName, 'C:\\NewName.pdf')

    Surely there is a more eloquent way to accomplish this?



    Todd7 <> wrote in news:YUslf.74898$2k5.73363
    @dukeread09:

    > I am writing a python program to load a pdf file into an IEHtmlWindow
    > which displays it through adobe acrobat reader 7. Depending on the
    > buttons the user clicks, the program moves it to another subdirectory
    > with a new name. I am using python 2.4 with wxpython 2.6 on a

    windowsxp
    > machine.
    >
    > I encounter a permission denied error when trying to move the file.

    It
    > appears to be caused due to the loading of the pdf file into the
    > IEHtmlWindow. The program is too long to post here, but below are

    some
    > snippets of the code.
    >
    > self.PDFPanel = iewin.IEHtmlWindow(self, -1, style =
    > wx.NO_FULL_REPAINT_ON_RESIZE)
    > ...
    > fileName = 'C:\\test.pdf'
    >
    > self.PDFPanel.LoadUrl(fileName)
    >
    > ...
    > # if I do this: self.PDFPanel.Destroy()
    > # then the following shutil.move works
    > # else I get a [Errno 13] Permission denied: 'C:\\test.pdf'
    > # tried loading another pdf file before doing shutil.move
    > # like: self.PDFPanel.LoadUrl(C:\\Temp.pdf) which loaded fine, but
    > # I still got a permission denied error
    >
    > shutil.move(fileName, 'C:\\NewName.pdf')
    >
    >
    > As stated in the comments above, if I destroy the IEHtmlWindow, then

    the
    > move works fine. I do not want to destroy it because I want to

    continue
    > using it to load the next pdf file to work on renaming. I tried
    > self.PDFPanel.LoadUrl('about:blank') before the shutil.move command.
    > The window displayed a blank screen, but still the permission denied
    > error. I then tried loading a different pdf file into the window,

    then
    > doing the shutil.move on the first pdf, but still the permission

    denied
    > error. If I destroy the window before the shutil.move command, then

    it
    > works fine, but I need the IEHtmlWindow for other work.
    >
    > Any suggestions on how to get the IEHtmlWindow to let go of the pdf

    file
    > before the shutil.move command without destroying the IEHtmlWindow all
    > together?
    >
    > Thanks,
    > Todd.
    >
     
    Todd7, Dec 7, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bmgz
    Replies:
    1
    Views:
    1,115
    Hans Nowak
    Dec 16, 2003
  2. Stéphane Ninin

    shutil.move, permission denied, why ?

    Stéphane Ninin, Apr 6, 2004, in forum: Python
    Replies:
    8
    Views:
    1,332
    Stéphane Ninin
    Apr 8, 2004
  3. Daniel Bickett

    shutil.move has a mind of its own

    Daniel Bickett, Jan 11, 2005, in forum: Python
    Replies:
    6
    Views:
    1,550
    Steve Holden
    Jan 12, 2005
  4. Delaney, Timothy C (Timothy)

    RE: shutil.move has a mind of its own

    Delaney, Timothy C (Timothy), Jan 11, 2005, in forum: Python
    Replies:
    3
    Views:
    446
    Neil Benn
    Jan 11, 2005
  5. Fletcher Johnson

    Why is the shutil module called shutil?

    Fletcher Johnson, Sep 24, 2011, in forum: Python
    Replies:
    11
    Views:
    878
    alex23
    Sep 26, 2011
Loading...

Share This Page