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

Customizes output directory #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion render_usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
urllib.request.urlretrieve(url, filename=outfile)
exit(0) # success
except Exception as e:
print(f"Could not download {url} from reMarkable USB web interface", file=sys.stderr)
print(f"Could not download {url} from reMarkable USB web interface. error: {e}", file=sys.stderr)
print(f"Make sure that Settings > Storage > USB web interface is enabled", file=sys.stderr)
exit(1) # failure
11 changes: 7 additions & 4 deletions rmirro.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
)
parser.add_argument("name", type=str, nargs="?", default="remarkable", help="SSH hostname of reMarkable reachable with \"ssh [name]\" without password (default: remarkable)")
parser.add_argument("-r", "--renderer", type=str, default="render_usb.py", metavar="ex", help="name of an executable in this project's directory such that \"ex infile outfile\" renders a reMarkable document with stem infile to the PDF outfile (default: render_usb.py - using the official USB web interface renderer)")
parser.add_argument("-o", "--output_dir", type=str, default="remarkable", help="name of directory for processed files.")
parser.add_argument("-v", "--verbose", action="store_true", help="print executed shell commands")

# TODO: --favorites-only (or by tags)
# TODO: --pull-only, --push-only, --backup, etc?
# TODO: let user exclude certain files? how would this pan out if they are suddenly included again?
# TODO: build symlink directory structure by tags?
# TODO: set --output directory
# TODO: support renderers that output e.g. SVG instead of PDF?

# Print an error message and exit
Expand Down Expand Up @@ -73,11 +73,12 @@ def log(self, text, urgency="normal", console=True, notification=True):

# Interface to communicate with reMarkable and operate on its raw file system
class Remarkable:
def __init__(self, ssh_name):
def __init__(self, ssh_name, output_dir):
self.ssh_name = ssh_name # e.g. "remarkable"
self.output_dir = output_dir # Output directory

self.raw_dir_remote = "/home/root/.local/share/remarkable/xochitl" # path to raw notes on RM
self.processed_dir_local = os.path.abspath(f"{self.ssh_name}") # path to rendered PDFs on PC (e.g. remarkable/)
self.processed_dir_local = os.path.abspath(f"{self.output_dir}") # path to rendered PDFs on PC (e.g. remarkable/)
self.raw_dir_local = os.path.abspath(f"{self.ssh_name}_metadata") # path to *.metadata files on PC (downloaded from RM) (e.g. remarkable_metadata/)
self.backup_dir = os.path.abspath(f"{self.ssh_name}_backup") # path to save a backup of all raw RM files on PC (e.g. remarkable_backup/)
self.last_sync_path = self.processed_dir_local + "/.last_sync" # path to a file on PC with the timestamp at which the last sync was performed
Expand Down Expand Up @@ -484,10 +485,12 @@ def sync_action_and_reason(rm_file, pc_file):
args = parser.parse_args()
ssh_name = getattr(args, "name")
renderer = getattr(args, "renderer")
output_dir = getattr(args, "output_dir")

logger = Logger()

rm = Remarkable(ssh_name)
os.makedirs(output_dir, exist_ok=True) # make a directory for processed files
rm = Remarkable(ssh_name, output_dir)
rm_root = RemarkableFile()
pc_root = ComputerFile(rm.processed_dir_local)

Expand Down