jar.JarManager
jar.JarManager(jar_dir=None, java_path='java')
Manages Josh JAR files.
Handles downloading, caching, and selecting between prod/dev/local jars.
Attributes
| jar_dir |
|
Directory where jars are stored. |
| java_path |
|
Path to java executable. |
Methods
download_jar
jar.JarManager.download_jar(mode, force=False, on_progress=None)
Download a jar from joshsim.org.
Parameters
| mode |
JarMode |
The jar mode (PROD or DEV). LOCAL mode raises ValueError. |
required |
| force |
bool |
If True, download even if jar already exists. |
False |
| on_progress |
Callable[[int, int], None] | None |
Optional callback(bytes_downloaded, total_bytes). |
None |
Returns
|
DownloadResult |
DownloadResult with download status. |
Raises
|
ValueError |
If mode is LOCAL (can’t download local jars). |
ensure_jars
jar.JarManager.ensure_jars(modes=None, force=False)
Ensure specified jars are downloaded.
Parameters
| modes |
list[JarMode] | None |
List of modes to download. Defaults to [PROD, DEV]. |
None |
| force |
bool |
If True, re-download even if jars exist. |
False |
Returns
|
dict[JarMode, DownloadResult] |
Dict mapping mode to download result. |
get_info
jar.JarManager.get_info(mode)
Get information about a jar.
Parameters
| mode |
JarMode |
The jar mode. |
required |
Returns
|
dict[str, str | None] |
Dict with ‘path’, ‘exists’, ‘version’, ‘hash’ keys. |
get_jar
jar.JarManager.get_jar(mode=JarMode.PROD, local_path=None, auto_download=True)
Get path to a jar, downloading if necessary.
Parameters
| mode |
JarMode |
The jar mode. |
JarMode.PROD |
| local_path |
Path | None |
Custom path for LOCAL mode. Ignored for other modes. |
None |
| auto_download |
bool |
If True, download prod/dev jars if not present. |
True |
Returns
|
Path |
Path to the jar file. |
Raises
|
FileNotFoundError |
If jar doesn’t exist and can’t be downloaded. |
get_jar_path
jar.JarManager.get_jar_path(mode)
Get the path where a jar would be stored.
Parameters
| mode |
JarMode |
The jar mode (PROD, DEV, or LOCAL). |
required |
Returns
|
Path |
Path to the jar file. |
jar_exists
jar.JarManager.jar_exists(mode)
Check if a jar exists.
Parameters
| mode |
JarMode |
The jar mode. |
required |
Returns
|
bool |
True if the jar file exists. |