davideuler / chm2pdf

Automatically exported from code.google.com/p/chm2pdf
GNU General Public License v2.0
0 stars 0 forks source link

Failing if file name is more than one word #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Let's say i have a file "Cool Scripts.chm". Trying to convert it
in pdf will fail.
> 
> $chm2pdf "Cool Scripts.chm"
> failed to open Cool
> failed to open Cool
> Converting individual HTML pages in PDF...
> Traceback (most recent call last):
>   File "/usr/bin/chm2pdf", line 176, in <module>
>     main(sys.argv)
>   File "/usr/bin/chm2pdf", line 172, in main
>     convert_to_pdf(cfile, filename, outputfilename)
>   File "/usr/bin/chm2pdf", line 106, in convert_to_pdf
>     pf=open(page_filename,'r')
> IOError: [Errno 2] No such file or directory:
'../tempout//8015final/toc.html'
> 

To overcome this bug do the following (for you file)

$cp "Cool Scripts.chm" CS.chm
$chm2pdf CS.chm

Original issue reported on code.google.com by haris.al...@gmail.com on 2 Nov 2007 at 5:37

GoogleCodeExporter commented 9 years ago
========================
$cp "Cool Scripts.chm" CS.chm
========================

can shel use apostroph (') instead of quotes (")?
Windows -- quotes
&nix -- apostroph

Original comment by abcde...@gmail.com on 4 Feb 2008 at 12:46

GoogleCodeExporter commented 9 years ago
I was going to report that too .. The chm2pdf 0.9 script cannot handle filenames
which contain shell delimiters ... like ( , ) , & , ;  and so .. 
The file name should be handle with proper escaping characters ... all those 
special
characters should be escaped internally throughout script execution. 

Original comment by amr.el.s...@gmail.com on 21 Feb 2008 at 4:00

GoogleCodeExporter commented 9 years ago
x2, error with spaces

Original comment by mrwaltercool on 21 Jul 2008 at 5:15

GoogleCodeExporter commented 9 years ago
me2... same problem

Original comment by interskh on 12 Nov 2008 at 6:20

GoogleCodeExporter commented 9 years ago
Everybody who uses spaces in filenames should accept the consequences! One of 
them is
that you have to always escape spaces and special characters on the command 
line.
This is a *very* nasty thing - I doubt that anybody who uses spaces in his 
filenames
has ever tried to type

ls my\ file\ with\ so\ many\ special\ \(and\ some\ less\ special\!\)\ chars\.chm

If you used the command line as often as I do, my dear friends, you would soon 
come
to the conclusion that spaces and special characters (like parentheses) in 
filenames
are simply impractical! You would then use my sanitize utility from

http://www.karakas-online.de/forum/viewtopic.php?t=10430

and be happy!

Anyway, another consequence is that such bugs get a low priority - sorry, but I 
am
not going to spend my time on a very avoidable problem, anytime soon! You 
should know
that space is an argument delimiter (i.e. it is used to separate the arguments 
to
commands) and should not be part of filenames, even if it is "possible" to do 
so!

This is not to say that I will *never* try to correct this "bug" - only that it 
may
take loooong time till I do!

Original comment by chriskar...@googlemail.com on 25 Nov 2008 at 10:14

GoogleCodeExporter commented 9 years ago
Issue 13 has been merged into this issue.

Original comment by chriskar...@googlemail.com on 25 Nov 2008 at 10:41

GoogleCodeExporter commented 9 years ago
I can confirm it too.

@5: That's a very inflexible attitude. Many of us who download documents have 
little
or no control over the rest of the internet how they name their documents ;)

Also, the majority does not rename every document they download to fit a 
certain file
naming convention.

Imho, the least you could do is to mention this in the man page or other
documentation. Maybe you do not see this as a bug, but most of your users will.

Thanks for a great app!

Original comment by carl.kih...@gmail.com on 18 Feb 2009 at 8:12

GoogleCodeExporter commented 9 years ago
chriskarakas @5:
"Everybody who uses spaces in filenames should accept the consequences! One of 
them
is that you have to always escape spaces and special characters on the command 
line."

This is not a problem with modern shells - bash and zsh will escape special
characters for you using tab completions. The problem is that even when properly
escaped, chm2pdf does not handle this internally. Python handles filenames with
spaces beautifully, and so should you.

"... and should not be part of filenames, even if it is "possible" to do so!"

POSIX filesystems only disallow ASCII NUL and the forward slash as possible 
character
filenames; I agree that not all characters should be used even despite this 
(newlines
being a good example), but spaces?! C'mon man. Spaces make great filename 
characters.
I won't use them for source code or configuration files, but everybody else uses
them, and programmers just have to deal with that.

Anyway, here's an initial patch for handling files with spaces:

http://nerv.metablu.com/files/public/0001-initial-fix-for-files-with-spaces.patc
h

or download the whole fixed script here:

http://nerv.metablu.com/files/public/chm2pdf

Original comment by sungmust...@gmail.com on 20 May 2009 at 10:59

GoogleCodeExporter commented 9 years ago
Thank you for your comments. And thanks for the patch too! I'm looking into it 
already.

Original comment by chriskar...@googlemail.com on 20 May 2009 at 12:18

GoogleCodeExporter commented 9 years ago

Original comment by chriskar...@googlemail.com on 20 May 2009 at 12:52

GoogleCodeExporter commented 9 years ago
That didn't fix it:

sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `extract_chmLib Ajax\ Design\ Patterns\ (2006).chm
/tmp/tmpfFzix3/Ajax\ Design\ Patterns\ (2006)> /dev/null 2>&1'
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `enum_chmLib Ajax\ Design\ Patterns\ (2006).chm >
"/tmp/tmpAnIlyp/Ajax\ Design\ Patterns\ (2006)/urlslist.txt"'
Traceback (most recent call last):                                              

                                                 File "/usr/bin/chm2pdf", line 1108,
in <module>
    main(sys.argv)
  File "/usr/bin/chm2pdf", line 1102, in main
    convert_to_pdf(cfile, filename, outputfilename, options)
  File "/usr/bin/chm2pdf", line 318, in convert_to_pdf
    objective_urls=get_objective_urls_list(filename)
  File "/usr/bin/chm2pdf", line 116, in get_objective_urls_list                     

flist=open(CHM2PDF_WORK_DIR+'/urlslist.txt','rU')
IOError: [Errno 2] No such file or directory: '/tmp/tmpAnIlyp/Ajax\\ Design\\
Patterns\\ (2006)/urlslist.txt'

Original comment by amphetam...@gmail.com on 24 Oct 2009 at 2:49

GoogleCodeExporter commented 9 years ago
It looks like the parens are tripping up the shell. Either the script needs to 
escape
all special shell characters, or filenames should be single quoted when 
shelling out.

Does it work without parens?

Original comment by sungmust...@gmail.com on 24 Oct 2009 at 3:19

GoogleCodeExporter commented 9 years ago
Yes, i tried escaping chars like Cool\ Scripts.chm and doesn't work. Is it for 
the Not Unicode native support of PYthon?? 

Original comment by santiago...@gmail.com on 16 Oct 2010 at 6:12

GoogleCodeExporter commented 9 years ago

Original comment by mt4...@gmail.com on 16 Jan 2011 at 11:46

Attachments:

GoogleCodeExporter commented 9 years ago
unfortunately proper escaping of characters won't fix code bugs. tab completion 
in zsh auto escapse characters... 

chm2pdf --webpage Design\ Patterns,\ Elements\ of\ Reusable\ Code,\ 1995.chm  
~/documents/books 
rm: cannot remove `/tmp/chm2pdf/orig/Design': No such file or directory
rm: cannot remove `Patterns,': No such file or directory
rm: cannot remove `Elements': No such file or directory
rm: cannot remove `of': No such file or directory
rm: cannot remove `Reusable': No such file or directory
rm: cannot remove `Code,': No such file or directory
rm: cannot remove `1995/*': No such file or directory
rm: cannot remove `/tmp/chm2pdf/work/Design': No such file or directory
rm: cannot remove `Patterns,': No such file or directory
rm: cannot remove `Elements': No such file or directory
rm: cannot remove `of': No such file or directory
rm: cannot remove `Reusable': No such file or directory
rm: cannot remove `Code,': No such file or directory
rm: cannot remove `1995/*': No such file or directory
failed to open Design
Traceback (most recent call last):
  File "/usr/bin/chm2pdf", line 1111, in <module>
    main(sys.argv)
  File "/usr/bin/chm2pdf", line 1107, in main
    convert_to_pdf(cfile, filename, outputfilename, options)
  File "/usr/bin/chm2pdf", line 326, in convert_to_pdf
    objective_urls=get_objective_urls_list(filename)
  File "/usr/bin/chm2pdf", line 114, in get_objective_urls_list
    flist=open(CHM2PDF_WORK_DIR+'/urlslist.txt','rU')
IOError: [Errno 2] No such file or directory: '/tmp/chm2pdf/work/Design 
Patterns, Elements of Reusable C

Original comment by XenoTerr...@gmail.com on 19 Jun 2011 at 1:20

GoogleCodeExporter commented 9 years ago
See https://bugs.launchpad.net/ubuntu/+source/chm2pdf/+bug/894193

I think this patch fixes this problem!

Original comment by reto.kn...@gmail.com on 24 Nov 2011 at 9:13

Attachments:

GoogleCodeExporter commented 9 years ago
See https://bugs.launchpad.net/ubuntu/+source/chm2pdf/+bug/894193

I think this patch fixes this problem!

Original comment by reto.kn...@gmail.com on 26 Nov 2011 at 9:50

Attachments:

GoogleCodeExporter commented 9 years ago
"Everybody who uses spaces in filenames should accept the consequences!"

Uh...

I will try the patch. Unbelievable this took 3 years to fix just because the 
authors weird opinion on spaces in filenames. (No, I don't like them too, but 
saying "Hey it's the file name and not a bug in my script" is - to put it 
mildly - an indicator of an immature programmer).

Well - ok, that was 3 years ago, maybe script and author have matured since 
then. ;-)

Original comment by risane...@gmail.com on 13 Jan 2012 at 8:54

GoogleCodeExporter commented 9 years ago
Unfortunately it had not fix pathes which have other special symbols like 
parenthesis.
Please look at https://bugzilla.redhat.com/show_bug.cgi?id=869041

I have made some additional patch, please revisit.

Original comment by pa...@hubbitus.com.ru on 18 May 2013 at 1:10

Attachments: