Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying the template file to its final destination/name does not work on Mac OS Big Sur #6

Closed
kellertuer opened this issue Apr 12, 2021 · 17 comments

Comments

@kellertuer
Copy link
Contributor

kellertuer commented Apr 12, 2021

I am not yet sure what causes this, copying the template file and renaming it worked and brought me the pdf. I have to check what might be different here after I have found the place where the coping takes place.

@gerw
Copy link
Owner

gerw commented Apr 12, 2021

I have no clue what you are talking about.

@kellertuer
Copy link
Contributor Author

kellertuer commented Apr 12, 2021

Calling doi2pdf now runs without an error.
It creates a template file, but not a pdf file in the folder I am in.
Copying said template file and renaming it to a pdf yields the correct pdf.
So something in the final copying does not work on Mac OS.
But I can currently not see where this is done, since shell/php/python is quite a mix and the php code is quite long with a lot of functions, none of which have documented functionality.

@gerw
Copy link
Owner

gerw commented Apr 12, 2021

Please give some sensible information. For example, what is the output of doi2pdf?

@kellertuer
Copy link
Contributor Author

Well, I had to check myself first, here's one that provides more information and not just output without an error

❯ doi2pdf 10.1007/978-3-319-68445-1_6
Traceback (most recent call last):
  File "/Users/ronnber/Repositories/numapde/numapde-bibliography/mathbin/doi2pdfname.py", line 9, in <module>
    tree = etree.parse(sys.argv[1], parser=parser)
  File "src/lxml/etree.pyx", line 3521, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1859, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1885, in lxml.etree._parseDocumentFromURL
  File "src/lxml/parser.pxi", line 1789, in lxml.etree._parseDocFromFile
  File "src/lxml/parser.pxi", line 1177, in lxml.etree._BaseParser._parseDocFromFile
  File "src/lxml/parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError
  File "/tmp/2368618976", line 1
lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1
INFO: This is doi2pdf 2017.1!
INFO: checking for php wrappers (should be all yes):
INFO:  - openssl: yes
INFO:  - http:    yes
INFO:  - https:   yes
INFO: Fetching http://dx.doi.org/10.1007/978-3-319-68445-1_6
INFO: Fetching https://dx.doi.org/10.1007/978-3-319-68445-1_6
INFO: Fetching http://link.springer.com/10.1007/978-3-319-68445-1_6
INFO: Fetching https://link.springer.com/10.1007/978-3-319-68445-1_6
INFO: Fetching https://link.springer.com/chapter/10.1007%2F978-3-319-68445-1_6
INFO: Fetching https://idp.springer.com/authorize?response_type=cookie&client_id=springerlink&redirect_uri=http%3A%2F%2Flink.springer.com%2Fchapter%2F10.1007%252F978-3-319-68445-1_6

@gerw
Copy link
Owner

gerw commented Apr 12, 2021

I don't think that this is the entire output.

@kellertuer
Copy link
Contributor Author

Well, that's all that is in my terminal, what are you missing?

@kellertuer
Copy link
Contributor Author

Invested some time and it might be curl does not work properly, so now doi2pdfname does actually work, but I am back to output without an error message (see below) that still does not do the final copy from said tmp file to the right place&name.

❯ doi2pdf 10.1007/978-3-319-68445-1_6
INFO: This is doi2pdf 2017.1!
INFO: checking for php wrappers (should be all yes):
INFO:  - openssl: yes
INFO:  - http:    yes
INFO:  - https:   yes
INFO: Fetching http://dx.doi.org/10.1007/978-3-319-68445-1_6
INFO: Fetching https://dx.doi.org/10.1007/978-3-319-68445-1_6
INFO: Fetching http://link.springer.com/10.1007/978-3-319-68445-1_6
INFO: Fetching https://link.springer.com/10.1007/978-3-319-68445-1_6
INFO: Fetching https://link.springer.com/chapter/10.1007%2F978-3-319-68445-1_6
INFO: Fetching https://idp.springer.com/authorize?response_type=cookie&client_id=springerlink&redirect_uri=http%3A%2F%2Flink.springer.com%2Fchapter%2F10.1007%252F978-3-319-68445-1_6
INFO: Fetching http://link.springer.com/chapter/10.1007%2F978-3-319-68445-1_6
INFO: Fetching https://link.springer.com/chapter/10.1007%2F978-3-319-68445-1_6
INFO: Fetching https://link.springer.com/content/pdf/10.1007%2F978-3-319-68445-1.pdf
INFO: PDF/PS found at https://link.springer.com/content/pdf/10.1007%2F978-3-319-68445-1.pdf
INFO: Writing contents to /tmp/312914748,

@gerw
Copy link
Owner

gerw commented Apr 12, 2021

This just means that doi2pdfname failed to produce a pdf name, see https://github.com/gerw/mathbin/blob/master/doi2pdf#L65. Hence, doi2pdf just saves the pdf in a temporary file.

@kellertuer
Copy link
Contributor Author

kellertuer commented Apr 12, 2021

The -z means empty? Hm, but

❯ doi2pdfname.sh 10.1007/978-3-319-68445-1_6
Nielsen_Barbaresco_Celledoni_Eidnes_Eslitzbichler_Schmeding_Celledoni_Eidnes_Eslitzbichler_Schmeding__Geometric_Science_of_Information_BOOK.pdf

Produces a name – ok it includes both the editors (the first two) and the authors, but that's a detail; so it does produce a name.

Edit: Yes compared to above, I updated/changes curl; I might add a file here explaining how Mac OS users can use this nice script collection.

@gerw
Copy link
Owner

gerw commented Apr 12, 2021

Are the variables $DOI and $FN in doi2pdf assigned correctly?

@kellertuer
Copy link
Contributor Author

Yes. If I do a echo $DOI directly after its definition (ie. after line 54) and similarly a echo $FN after line 62 the beginning of the output is

❯ doi2pdf 10.1007/978-3-319-68445-1_6
10.1007/978-3-319-68445-1_6
Nielsen_Barbaresco_Celledoni_Eidnes_Eslitzbichler_Schmeding_Celledoni_Eidnes_Eslitzbichler_Schmeding__Geometric_Science_of_Information_BOOK.pdf
INFO: This is doi2pdf 2017.1!
[...]

@gerw
Copy link
Owner

gerw commented Apr 13, 2021

And the file is still saved at the wrong place? Strange.

Is $filename correct at https://github.com/gerw/mathbin/blob/master/doi2pdf.php#L532 ??

@kellertuer
Copy link
Contributor Author

The tmp file is created correctly but the final move/copy does not seem to happen.

The filename printed with write_info($filename); seems to be correct, yes. I will further investigate tonight.

@gerw
Copy link
Owner

gerw commented Apr 13, 2021

There is no copying involved. The filename is passed to scan_for_pdf (https://github.com/gerw/mathbin/blob/master/doi2pdf.php#L533) and then the file is saved directly there: https://github.com/gerw/mathbin/blob/master/doi2pdf.php#L343.

Your observed behavior seems to be very strange.

@kellertuer
Copy link
Contributor Author

It seems to have been some strange behaviour in curl or something. Installing curl via brew (again) has solved the problem. Should I maybe add a small part to the Readme how one can use this nice collection of scripts also with Mac OS?

@gerw
Copy link
Owner

gerw commented Apr 15, 2021

Yes, feel free to set up a pull request.

@kellertuer
Copy link
Contributor Author

I added #7 which finishes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants