Comments (13)
See #11 and especially #8 for why I switched away from WeasyPrint.
I don't have access to Windows, but this "Error" is actually a harmless warning (i.e. the resume.pdf file is successfully built) on Windows in Github Actions: https://github.com/mikepqr/resume.md/runs/2901233186?check_suite_focus=true.
I believe it can be eliminated by upgrading to a more recent version of Python (e.g. 3.8, 3.9 or 3.10).
Given it is harmless then I'd be glad to take a PR that hides it on 3.7, but I don't want to revert to WeasyPrint just to get rid of it.
But like I said, I don't have access to Windows to test anything, so please let me know if any of the above is wrong (e.g. it's not harmless, it's not fixed by upgrading Python to 3.8+).
from resume.md.
According to https://bugs.python.org/issue26660, the snippet at https://docs.python.org/3/library/shutil.html?highlight=shutil#rmtree-example might help. I'd probably need to add that here
Line 162 in f1b0699
from resume.md.
OK, sounds promising! Also sounds like it might break macOS and Linux, so I will be sure to run rests on the PR 😄
from resume.md.
Can confirm that i am seeing a similar error
from resume.md.
I tried using weasyprint
instead of headless chrome and pdf generation works fine. Is there any reason why we cannot use weasyprint?
I also tried pdfkit
but it has been updated in a while.
from resume.md.
Thanks for all the details @mikepqr . I'll try to make this change.
Please note that i am on Python 3.9.6 and i am still seeing the error :)
from resume.md.
Also, there are problems with WeasyPrint. :)
As already mentioned in an issue here, the most annoying thing about WeasyPrint is probably the installation process. Its quite convoluted. And then the output is also not satisfactory. I was trying to achieve a LaTeX look - the html looks fine but the pdf looks all weird.
So i agree, its probably best to stick with headless chrome.
from resume.md.
Do note that, for me, it does not write the resume.pdf file.
This is the output i see:
PS C:\work\code\resume.md> python resume.py
Wrote resume.html
Found Chrome or Chromium at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Traceback (most recent call last):
File "C:\work\code\resume.md\resume.py", line 210, in <module>
write_pdf(html, prefix=prefix, chrome=args.chrome_path)
File "C:\work\code\resume.md\resume.py", line 139, in write_pdf
subprocess.run(
File "C:\Python39\lib\subprocess.py", line 507, in run
stdout, stderr = process.communicate(input, timeout=timeout)
File "C:\Python39\lib\subprocess.py", line 1126, in communicate
self.wait()
File "C:\Python39\lib\subprocess.py", line 1189, in wait
return self._wait(timeout=timeout)
File "C:\Python39\lib\subprocess.py", line 1470, in _wait
result = _winapi.WaitForSingleObject(self._handle,
KeyboardInterrupt
from resume.md.
OK. So i added the --repl
flag while calling chrome.exe
in subprocess.run()
and now we can see the real reason for the failure:
Note that although it says Wrote resume.pdf
, the file was not created.
C:\work\code\resume.md [main ≡ +4 ~4 -1 !]> python resume.py
Wrote resume.html
Found Chrome or Chromium at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
>>>
Wrote resume.pdf
Could not delete C:\Users\abmandal\AppData\Local\Temp\resume.md_iv3sprky
[WinError 5] Access is denied: 'C:\\Users\\abmandal\\AppData\\Local\\Temp\\resume.md_iv3sprky\\CrashpadMetrics-active.pma'
Exception ignored in: <finalize object at 0x1e6aa6d0700; dead>
Traceback (most recent call last):
File "C:\Python39\lib\weakref.py", line 580, in __call__
return info.func(*info.args, **(info.kwargs or {}))
File "C:\Python39\lib\tempfile.py", line 816, in _cleanup
cls._rmtree(name)
File "C:\Python39\lib\tempfile.py", line 812, in _rmtree
_shutil.rmtree(name, onerror=onerror)
File "C:\Python39\lib\shutil.py", line 740, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Python39\lib\shutil.py", line 618, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Python39\lib\tempfile.py", line 804, in onerror
cls._rmtree(path)
File "C:\Python39\lib\tempfile.py", line 812, in _rmtree
_shutil.rmtree(name, onerror=onerror)
File "C:\Python39\lib\shutil.py", line 740, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Python39\lib\shutil.py", line 599, in _rmtree_unsafe
onerror(os.scandir, path, sys.exc_info())
File "C:\Python39\lib\shutil.py", line 596, in _rmtree_unsafe
with os.scandir(path) as scandir_it:
NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\abmandal\\AppData\\Local\\Temp\\resume.md_iv3sprky\\CrashpadMetrics-active.pma'
from resume.md.
No idea, I'm afraid. The error should be harmless to our goals (I think it's Chrome's own telemetry/logging tempfile/cleanup failing) but it raises which causes resume.py to receive the exception. You could try catching NotADirectoryError
just before here
Line 149 in f1b0699
from resume.md.
OK. So i re-approached the problem from a different angle, and it works 😀
- I have gotten rid of the temporary directory thingy altogether.
- I have created a separate function for writing pdf for
win32
- i cannot pass the entire html in base64 encoded format via the command line. I get a
command too long
error. So i must first create the html file and then create the pdf file from the html file. - As a result, the args are not respected. IMHO, this is okay for now because the tool actually works now for win32 users 🤣
- So in philosophy, I am simply trying to run the below PowerShell command from Python:
& 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe' --headless --disable-gpu --run-all-compositor-stages-before-draw --print-to-pdf-no-header --virtual-time-budget=5000 --no-margins --print-to-pdf=C:\work\code\resume.md\resume.pdf C:\work\code\resume.md\resume.html
I will raise a PR tomorrow as its quite late here 😄
from resume.md.
OK, sounds promising! Also sounds like it might break macOS and Linux, so I will be sure to run rests on the PR 😄
I think it will not break for macOS and Linux because there are two separate functions now - one for win32 and another for macOS/Linux. But yes, you must test it, especially because I have not.
from resume.md.
For anyone else having this issue, you can find a recipe for a work-around in:
- this answer to the question "Deleting read-only directory in Python" on Stack Overflow
- akaihola/darker#453
from resume.md.
Related Issues (19)
- Use Github Actions to build PDF HOT 4
- Fix Chrome SIGABRT on macOS HOT 2
- chrome branch fails on windows HOT 3
- [Feature Request] Hot reload on file change (.md/.css) HOT 4
- Add table support HOT 3
- "InitializeSandbox() called with multiple threads in process gpu-process" on Linux HOT 1
- Make this project a pip-installable package
- Why markdown over json? HOT 1
- Having an empty line before the first `#` gives an IndexError HOT 2
- Turn this repo into a template rather than telling people to fork
- Python-Markdown 3.4 has been released and makes resume.md buggy HOT 5
- Font awesome support for PDF HOT 6
- [Help] Date right aligned when using bullet points HOT 1
- Headers & Footers on latest Chrome HOT 2
- Warnings about box-shadow and media type HOT 1
- Adding a 'requirements.txt' file HOT 1
- Eliminate weasyprint dependency HOT 1
- Enable attr_list markdown extension to give users more flexibilty and make default CSS less fragile
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resume.md.