Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

[WIP] Download annotated notebooks #34

Closed
wants to merge 44 commits into from
Closed

[WIP] Download annotated notebooks #34

wants to merge 44 commits into from

Conversation

peerdavid
Copy link
Contributor

@peerdavid peerdavid commented Dec 4, 2018

This allows to execute geta (read annotated file) and mgeta (read multiple annotated files)
Note: With this PR we introduce additional dependencies (the transformation is executed i.e. in a bash script). Those are listed in README.md

ToDo's

  • Set modification date of pdf file and download only if content changed
  • Bug: Non annotated pdf files are not downloaded correctly
  • Bug: Ignore epub files
  • Add function to validate if all tools are installed to execute geta, mgeta
  • Implement rM2svg instead of calling a script
  • Implement exportAnnotatedPdf instead of calling a script
  • Bug: Annotations of rotated pdf files are not rotated

@peerdavid peerdavid mentioned this pull request Dec 4, 2018
@juruen
Copy link
Owner

juruen commented Dec 8, 2018

@peerdavid 👋 thank you for the PR!

I don't have much time this week to look at this but my proposal would be something along these lines:

  1. We merge this into master but we sort of make sure that this is a an "advanced feature". In the sense that we are clear that you don't need to install all these dependencies if you don't really need to get the annotated PDF docs.
  2. We slowly start to to migrate the scripts to pure Go to simplify the dependencies. No rush here. I'll probably have some time during the holidays. And of course, you are more than welcome to help with that!

What do you think?

@peerdavid
Copy link
Contributor Author

@juruen

  1. Sounds good to me. Possible we can also add a check if all tools are installed and warn the user that this feature is not available when geta / mgeta is called or something like that?
  2. I also think that it totally makes sense to replace the exportAnnotatedPdf and the rM2svg script. In the holidays I should also have some time and of course I will help with that :)

Copy link
Owner

@juruen juruen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank so much for doing this!

I added a few minor comments.

I would also like to change the README.md to be more explicit about this being optional. As I said in the issue, I don't want to discourage non-power users by letting them think they need to install a lot of dependencies. I'm going to propose some changes to your PR in a separate one to see if you are cool with them.

Thank you!

shell/geta.go Outdated
if err != nil {
// If we could not parse the time correctly, we still continue
// with the execution such that the pdf is downloaded...
fmt.Println(err)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use the logging facilities instead of standard output/err?

Something like:

  log.Trace.Println(err)

or in this case, if this is just a warning:

  log.Warning.Println(err)

In general, we should try to use the log facilities instead of fmt.Print as much as we can in this file. Either that or use the ishell context to print relevant stuff.

shell/geta.go Outdated
// If we could not parse the time correctly, we still continue
// with the execution such that the pdf is downloaded...
fmt.Println(err)
fmt.Println("(Warning) Could not parse modified time. Overwrite existing file.")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

shell/geta.go Outdated
if !os.IsNotExist(err) {
outputFileModTime := outputFile.ModTime()
if(outputFileModTime.Equal(modifiedClientTime)){
fmt.Println("Nothing changed since last download. Skip. ")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. This looks like log.Trace candidate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comments => fixed all invalid log statements

shell/geta.go Outdated

// Convert to pdf
exportPdf := os.Getenv("GOPATH") + "/src/github.com/juruen/rmapi/tools/exportAnnotatedPdf"
rM2svg := os.Getenv("GOPATH") + "/src/github.com/juruen/rmapi/tools/rM2svg"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we create a file/function where we encapsulate checks to verify if the required tools are installed. We can then use it in https://github.com/juruen/rmapi/blob/master/shell/shell.go#L54 to optinally add these new commands to the shell.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I will fix a bug that I found right now and afterwards I will start with this verification

@peerdavid peerdavid changed the title Download annotated notebooks [WIP] Download annotated notebooks Dec 24, 2018
README.md Outdated


# Thanks to
[1] rmapi, https://github.com/juruen/rmapi <br />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can drop this line :)

@mseri
Copy link

mseri commented Apr 11, 2019

Does this support the latest remarkable line format? The export notebook can be made platform agnostic as done here: reHackable/maxio#22 (and probably it could be ported to go in a similar fashion)

@peerdavid
Copy link
Contributor Author

Does this support the latest remarkable line format? The export notebook can be made platform agnostic as done here: reHackable/maxio#22 (and probably it could be ported to go in a similar fashion)

Currently not but I will update to the latest line format (in the fork that I created) when my RM device is also running on version 1.7

@lobre
Copy link
Collaborator

lobre commented Apr 11, 2019

Hello @mseri,

This normally temporary feature (as it should be shifted to a full go implementation someday) relies as you said on the rM2svg of https://github.com/reHackable/maxio.

Effectively, it seems to be working with the previous .lines version (see the header here)

Apparently, there is an open issue on the project here.

So I think the implementation has to be made there.

However, we started slowly the shifting to a pure go implementation. We created and merged recently the package github.com/juruen/rmapi/encoding/rm that has the responsibility to encode/decode a .rm file (and that supports only the latest v3 format).

See https://github.com/juruen/rmapi/blob/master/encoding/rm/rm.go#L43.

I am not sure whether it makes sense to continue supporting the previous format as well.

@peerdavid, just seen you reply and did not know that you started a fork with the support of the new format! Good news!

@mseri
Copy link

mseri commented Apr 11, 2019

@lobre there is already a version working with the new format (see the comments here reHackable/maxio#22 (comment) and here reHackable/maxio#27 (comment), the last version of the script is http://www.ucl.ac.uk/~ucecesf/tmp/rm2svg.py). The https://github.com/reHackable/maxio repo seems unmaintained, there are pending PRs to get rid of external dependencies and other improvements that are ignored since months.

I don't think that supporting the old version makes sense, the recent updates are more stable, more ergonomic and more flexible, I hope people are uploading their remarkables.

@peerdavid peerdavid closed this Jul 20, 2019
@martin-braun
Copy link

@peerdavid mgeta is not listed when doing rmapi help

@peerdavid
Copy link
Contributor Author

Sry, my initial implementation which uses a python script etc. is no more maintained - they implemented in my opinion a much better golang native version of mgeta which should also be in the masterbranch.

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

Successfully merging this pull request may close these issues.

5 participants