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

docker image load local files #34

Closed
guyvdbroeck opened this issue Mar 20, 2020 · 7 comments
Closed

docker image load local files #34

guyvdbroeck opened this issue Mar 20, 2020 · 7 comments

Comments

@guyvdbroeck
Copy link

I cannot seem to be able to load local files using the docker image.

~/Downloads$ docker run --rm -v "${HOME}/.rmapi:/home/user/.rmapi:rw" p2r -v main.pdf
/usr/local/lib/python3.7/site-packages/weasyprint/document.py:36: UserWarning: There are known rendering problems and missing features with cairo < 1.15.4. WeasyPrint may work with older versions, but please read the note about the needed cairo version on the "Install" page of the documentation before reporting bugs. http://weasyprint.readthedocs.io/en/latest/install.html
'There are known rendering problems and missing features with '
Traceback (most recent call last):
File "/usr/local/bin/p2r", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/paper2remarkable/main.py", line 13, in main
sys.exit(realmain())
File "/usr/local/lib/python3.7/site-packages/paper2remarkable/ui.py", line 138, in main
url, cookiejar = follow_redirects(args.input)
File "/usr/local/lib/python3.7/site-packages/paper2remarkable/utils.py", line 118, in follow_redirects
url, headers=HEADERS, allow_redirects=False, cookies=jar
File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 104, in head
return request('head', url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 516, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 459, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 314, in prepare
self.prepare_url(url, params)
File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 388, in prepare_url
raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'main.pdf': No schema supplied. Perhaps you meant http://main.pdf?

@GjjvdBurg
Copy link
Owner

Could that be because the file is not accessible in the docker container? What if you map the location of the local folder (where main.pdf resides) as a volume too?

$ docker run --rm -v "${HOME}/.rmapi:/home/user/.rmapi:rw" -v "$(pwd):/home/user:r" p2r -v main.pdf

If that works I can add it to the documentation.

@guyvdbroeck
Copy link
Author

That must be it yes. I managed to get the non-docker install to work, so I am fine for now. Thanks!

@GjjvdBurg
Copy link
Owner

Glad you got it to work!

@stekern
Copy link

stekern commented Apr 8, 2020

I had the same issue as well. Created a short wrapper function that mounts the local file, and it's been working well for me :-)

function p2r {
  local input="$1"
  shift
  if [[ "$input" =~ ^http ]]; then
    docker run --rm -v "${HOME}/.rmapi:/home/user/.rmapi:rw" p2r "$input" "$@" --verbose
  else
    if [[ "$input" =~ ^.*\.pdf$ ]] && [ -e "$input" ]; then
      local file="$(basename "$input")"
      docker run --rm -v "${HOME}/.rmapi:/home/user/.rmapi:rw" -v "$input:/pdfs/$file" p2r "/pdfs/$file" "$@" --verbose
    fi
  fi
}

@GjjvdBurg
Copy link
Owner

Thanks for the comment @stekern! I'll add it to the readme

@jerrison
Copy link

I had the same issue as well. Created a short wrapper function that mounts the local file, and it's been working well for me :-)

function p2r {
  local input="$1"
  shift
  if [[ "$input" =~ ^http ]]; then
    docker run --rm -v "${HOME}/.rmapi:/home/user/.rmapi:rw" p2r "$input" "$@" --verbose
  else
    if [[ "$input" =~ ^.*\.pdf$ ]] && [ -e "$input" ]; then
      local file="$(basename "$input")"
      docker run --rm -v "${HOME}/.rmapi:/home/user/.rmapi:rw" -v "$input:/pdfs/$file" p2r "/pdfs/$file" "$@" --verbose
    fi
  fi
}

Hi @stekern, I am using Windows and have docker installed. How do I use this wrapper to call this command directly from PowerShell?

@stekern
Copy link

stekern commented Dec 29, 2020

@jerrison I've only used the Bash script on MacOS and Linux, and I'm not that familiar with PowerShell, unfortunately.

If you're using Windows and Windows Subsystem for Linux (WSL), I think you may be able to use the script with only minor modifications (e.g., the volume paths in the docker commands may need to be updated due to different path formats in Windows vs. UNIX).

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

4 participants