codexctl 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: codexctl
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Automated update managment for the ReMarkable tablet
5
5
  License: GPLv3
6
6
  Author: Jayy001
@@ -56,24 +56,20 @@ class Manager:
56
56
 
57
57
  version = args.get("version", None)
58
58
 
59
- if version == "latest":
60
- version = self.updater.get_latest_version(remarkable_version)
61
- elif version == "toltec":
62
- version = self.updater.get_toltec_version(remarkable_version)
59
+ if remarkable_version:
60
+ if version == "latest":
61
+ version = self.updater.get_latest_version(remarkable_version)
62
+ elif version == "toltec":
63
+ version = self.updater.get_toltec_version(remarkable_version)
63
64
 
64
65
  ### Download functionalities
65
66
  if function == "list":
66
- print(
67
- f"""
68
- ReMarkable Paper Pro:
69
- {'\n'.join(list(self.updater.remarkablepp_versions.keys()))}
70
-
71
- ReMarkable 2:
72
- {'\n'.join(list(self.updater.remarkable2_versions.keys()))}
67
+ remarkable_pp_versions = "\n".join(self.updater.remarkablepp_versions.keys())
68
+ remarkable_2_versions = "\n".join(self.updater.remarkable2_versions.keys())
69
+ remarkable_1_versions = "\n".join(self.updater.remarkable1_versions.keys())
73
70
 
74
- ReMarkable 1:
75
- {'\n'.join(list(self.updater.remarkable1_versions.keys()))}
76
- """
71
+ print(
72
+ f"ReMarkable Paper Pro:\n{remarkable_pp_versions}\n\nReMarkable 2:\n{remarkable_2_versions}\n\nReMarkable 1:\n{remarkable_1_versions}"
77
73
  )
78
74
 
79
75
  elif function == "download":
@@ -95,9 +91,6 @@ ReMarkable 1:
95
91
  )
96
92
 
97
93
  if function == "extract":
98
- if sys.platform != "linux":
99
- raise NotImplementedError
100
-
101
94
  if not args["out"]:
102
95
  args["out"] = os.getcwd() + "/extracted"
103
96
 
@@ -135,15 +128,15 @@ ReMarkable 1:
135
128
  )
136
129
 
137
130
  try:
138
- image, volume = get_update_image(args.file)
139
- inode = volume.inode_at(args.target_path)
131
+ image, volume = get_update_image(args["file"])
132
+ inode = volume.inode_at(args["target_path"])
140
133
 
141
134
  except FileNotFoundError:
142
- print(f"'{args.target_path}': No such file or directory")
135
+ print(f"{args['target_path']}: No such file or directory")
143
136
  raise FileNotFoundError
144
137
 
145
138
  except OSError:
146
- print(f"'{args.target_path}': {os.strerror(e.errno)}")
139
+ print(f"{args['target_path']}: {os.strerror(e.errno)}")
147
140
  sys.exit(e.errno)
148
141
 
149
142
  if function == "cat":
@@ -197,6 +190,11 @@ ReMarkable 1:
197
190
  authentication=args["password"],
198
191
  )
199
192
 
193
+ if version == "latest":
194
+ version = self.updater.get_latest_version(remarkable.hardware)
195
+ elif version == "toltec":
196
+ version = self.updater.get_toltec_version(remarkable.hardware)
197
+
200
198
  if function == "status":
201
199
  beta, prev, current, version_id = remarkable.get_device_status()
202
200
  print(
@@ -239,25 +237,35 @@ ReMarkable 1:
239
237
 
240
238
  #### PREVENT USERS FROM INSTALLING NON-COMPATIBLE IMAGES ####
241
239
 
242
- # TODO: Downgrade from versions above 3.11 to versions below 3.11 (We alredy know how to do this with #71)
243
- # TODO: Upgrade from versions below 3.11 to versions above 3.11 (Easy way: upgrade to 3.11.2.5 to get the new update engine, then upgrade again to the specific version)
244
-
245
- if device_version_uses_new_engine != update_file_requires_new_engine:
246
- raise SystemError(
247
- "Incompatible update file with current reMarkable update engine. See #71"
248
- )
240
+ if device_version_uses_new_engine:
241
+ if not update_file_requires_new_engine:
242
+ raise SystemError("Cannot downgrade to this version as it uses the old update engine, please manually downgrade.")
243
+ # TODO: Implement manual downgrading.
244
+ # `codexctl download --out . 3.11.2.5`
245
+ # `codexctl extract --out 3.11.2.5.img 3.11.2.5_reMarkable2-qLFGoqPtPL.signed`
246
+ # `codexctl transfer 3.11.2.5.img ~/root`
247
+ # `dd if=/home/root/3.11.2.5.img of=/dev/mmcblk2p2` (depending on fallback partition)
248
+ # `codexctl restore`
249
+
250
+ else:
251
+ if update_file_requires_new_engine:
252
+ raise SystemError("This version requires the new update engine, please upgrade your device to version 3.11.2.5 first.")
249
253
 
250
254
  #############################################################
251
255
 
256
+ update_file_requires_new_engine = False
257
+ device_version_uses_new_engine = False
258
+
252
259
  if not update_file_requires_new_engine:
253
- if not os.path.exists("updates"):
254
- os.mkdir("updates")
255
- if update_file:
256
- shutil.move(update_file, "updates")
257
- update_file = get_available_version(version)
258
- made_update_folder = True # Delete at end
260
+ if update_file: # Check if file exists
261
+ if not (os.path.dirname(os.path.abspath(update_file)) == os.path.abspath("updates")):
262
+ if not os.path.exists("updates"):
263
+ os.mkdir("updates")
264
+ shutil.move(update_file, "updates")
265
+ update_file = get_available_version(version)
266
+ made_update_folder = True # Delete at end
259
267
 
260
- # If version was a valid location file, update_file will be the location.
268
+ # If version was a valid location file, update_file will be the location else it'll be a version number
261
269
 
262
270
  if not update_file:
263
271
  temp_path = tempfile.mkdtemp()
@@ -342,7 +350,7 @@ def main() -> None:
342
350
  download.add_argument("version", help="Version to download")
343
351
  download.add_argument("--out", "-o", help="Folder to download to", default=None)
344
352
  download.add_argument(
345
- "--hardware", "--h", help="Hardware to download for", required=True
353
+ "--hardware", "-hd", help="Hardware to download for", required=True
346
354
  )
347
355
 
348
356
  ### Backup subcommand
@@ -47,8 +47,11 @@ class DeviceManager:
47
47
  with ftp.file("/sys/devices/soc0/machine") as file:
48
48
  machine_contents = file.read().decode("utf-8").strip("\n")
49
49
  else:
50
- with open("/sys/devices/soc0/machine") as file:
51
- machine_contents = file.read().decode("utf-8").strip("\n")
50
+ try:
51
+ with open("/sys/devices/soc0/machine") as file:
52
+ machine_contents = file.read().decode("utf-8").strip("\n")
53
+ except FileNotFoundError:
54
+ machine_contents = "tests"
52
55
 
53
56
  if "reMarkable Ferrari" in machine_contents:
54
57
  self.hardware = "ferrari"
@@ -145,6 +145,10 @@ class UpdateManager:
145
145
 
146
146
  if "ferrari" in device_type:
147
147
  raise SystemExit("ReMarkable Paper Pro does not support toltec")
148
+ elif "1" in device_type:
149
+ device_type = "rm1"
150
+ else:
151
+ device_type = "rm2"
148
152
 
149
153
  response = requests.get("https://toltec-dev.org/stable/Compatibility")
150
154
  if response.status_code != 200:
@@ -349,6 +353,11 @@ class UpdateManager:
349
353
 
350
354
  return filename
351
355
 
356
+ @staticmethod
357
+ def __max_version(versions: list) -> str:
358
+ """Returns the highest avaliable version from a list with semantic versioning"""
359
+ return sorted(versions, key=lambda v: tuple(map(int, v.split("."))))[-1]
360
+
352
361
  @staticmethod
353
362
  def uses_new_update_engine(version: str) -> bool:
354
363
  """
@@ -360,9 +369,4 @@ class UpdateManager:
360
369
  Returns:
361
370
  bool: If it uses the new update engine or not
362
371
  """
363
- return int(version.split(".")[0]) >= 3 and int(version.split(".")[1]) >= 11
364
-
365
- @staticmethod
366
- def __max_version(versions: list) -> str:
367
- """Returns the highest avaliable version from a list with semantic versioning"""
368
- return sorted(versions, key=lambda v: tuple(map(int, v.split("."))))[-1]
372
+ return int(version.split(".")[0]) >= 3 and int(version.split(".")[1]) >= 11
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "codexctl"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "Automated update managment for the ReMarkable tablet"
5
5
  authors = ["Jayy001 <github@skii.dev>"]
6
6
  license = "GPLv3"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes