Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-08-2018, 09:36 PM   #1
Registered: Oct 2004
Distribution: Debian/Ubuntu, Arch, Gentoo, Void
Posts: 109

Rep: Reputation: 22
Pythonistas to the rescue? (Why is this script erroring out?)

I'll start off by saying that I'm no sort of python programmer: it taxes my abilities just to cobble together simple bash scripts. So what I'm trying to do and will ask about in this thread is to use a python script someone else created. I want to get some help here in understanding why I can't get it to complete the task for which it's designed. The script can be found at

It's a promising little piece of work I'd really like to use right now. It's supposed to download folders and e-mails from an IMAP server and create a sort of back-up in html. That's very appealing at the moment since I'm going to be closing one of my e-mail accounts and would like to have a back-up of the relatively small (ca. 4k) cache of mails I have there.

The script is a bit dated, the last release apparently having been in 2013, but I do still have python 2.7 on one of my machines so I decided I should be able to run it. And yes, I know I can export my mail to a compressed file using a web interface--but I'd rather have the archive be easily browsable, say, using a text-mode browser.

Anyway, I've downloaded the script and its config file, the latter of which I edited appropriately. The script does actually log into my account, creates local directories and downloads stuff. But it somehow can't complete the final step of creating the email-report-1.html file (my interpretation of the script is that one of those should be in each directory and sub-directory the script creates locally) which, I assume is crucial to making the resulting archive browseable.

Despite the fact that a whole trove of files and folders show up in the target directory--including, importantly, an index.html--once the process finally erros out, opening index.html in a web browser does not allow me to follow any of the links that are supposed to show the contents of downloaded messages within their folders.

The final, apparently show-stopping, error message is as follows:
 . . .
 . . . 
Saving message 3373.
Done with folder: INBOX.

Getting messages from server from folder: Misc.
Done with folder: Misc.

Getting messages from server from folder: Priority.
Done with folder: Priority.

Processing folder: [Gmail]/All Mail.
Traceback (most recent call last):
  File "/home/user/bin/", line 885, in <module>
    copy(inc_location, folder + "/inc/")
  File "/home/user/bin/", line 391, in copy
    shutil.copytree(src, dst)
  File "/usr/lib/python2.7/", line 185, in copytree
    names = os.listdir(src)
OSError: [Errno 2] No such file or directory: 'inc'
Anyway, I thought the pythonistas on this list should be able to look at the error output and have a quick gander at the script and maybe get an idea of what could be going wrong. Hopefully some simple modification might restore the script's expected behavior. Of course it would be even more wonderful if it could be translated so that it would work in a more recent version of python, but that might be quite a lot of work.

Btw my config file looks something like this:
imap_server =
imap_user =
imap_password = users_password
imap_folder = NoPriv_All

ssl = true
incremental_backup = false # tried true here too--no difference
Thanks in advance for any suggestions that will help get this script functioning as needed.

PS Though the script is not all that long I decided it would be best simply to link to it at rather than copy and paste the whole thing into this thread.

Last edited by jamtat; 03-08-2018 at 09:39 PM.
Old 03-08-2018, 10:57 PM   #2
Registered: Apr 2012
Location: California
Posts: 401
Blog Entries: 15

Rep: Reputation: Disabled
What I *think* is going on is that the script assumes that you're always going to run it from the directory it creates when you clone the repo.

git clone git://
cd NoPriv
vim nopriv.ini
This way works fine for me.

The problem you're seeing is that the script expects the directory and files 'inc/css/bootstrap.css' from the git repository to be in the same directory as the script is being run from.
If you would like to continue running the script this way, copy that directory to wherever you're running the script from. Possibly like this:
mkdir email_backup
cd email_backup
cp -R ~/path/to/NoPriv/inc .
python ~/path/to/NoPriv/
Hopefully that fixes the error on your end.
1 members found this post helpful.
Old 03-08-2018, 11:37 PM   #3
Registered: Oct 2004
Distribution: Debian/Ubuntu, Arch, Gentoo, Void
Posts: 109

Original Poster
Rep: Reputation: 22
Yes, Myk267, you seem to have discerned correctly where the problem lies. So I am obviously no more conversant in using git than I am in python. Following your suggestions I was able to get the script to work as advertised. A description along the lines you've explained really needs to be added to the github readme section of this project for dummies like myself. But it looks like nothing much has been done there since 2013 so I suspect the developer may be in the process of abandoning the project and it may be therefore futile to suggest making that sort of addition. Anyway, I need to mark this issue solved and should probably change the title since the central issue is really not a python one.

Last edited by jamtat; 03-08-2018 at 11:40 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ksh script erroring with "more tokens expected" Works on SLES 9 & 10 not 11 George.evans Linux - Software 2 01-11-2013 08:13 AM
How to Rescue a System with Automation Script in Rescue Mode Neron.L Linux - Server 1 12-13-2012 01:12 PM
1 script 8 boxes and it is erroring on 3 of them cat555 Linux - Newbie 3 12-16-2008 04:43 PM
Linux Rescue script question, in rescue mode vijay_aras Linux - General 1 01-09-2008 06:03 PM
Streamzap remote and LIRC rpmbuild erroring out dittohead Linux - Hardware 2 01-02-2006 05:35 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration