os.system
import os
Everything here is re-exported by
os, soimport osis enough and the names are called asos.*. Importingos.systemon its own works too and reaches the same definitions.
Facts about the current process, the Zuri runtime, and the machine it’s running on.
Constants
version
os.version: string
The current Zuri version.
target
os.target: string
The platform the running runtime was built for, as a target triple:
x86_64-unknown-linux-gnu, aarch64-apple-darwin,
x86_64-pc-windows-msvc and so on. Release archives are named by it,
which is what makes it the way to find a runtime for this machine.
%> os.target
'x86_64-unknown-linux-gnu'
vm_version
os.vm_version: string
The current Zuri VM version.
platform
os.platform: string
The name of the current platform in string or unknown if the platform
name could not be determined.
Example,
%> import os
%> os.platform
'osx'
args
os.args: list
The command line, as the running script sees it.
The first entry is the path to the Zuri executable and the second is the
script being run. Everything after those two was meant for the script
itself, so a program reads its own arguments from args[2,] and gets
the same list whether it was launched with zuri run or as a command.
%> import os
%> os.args
['/usr/local/bin/zuri', '/home/ada/greet.zu', '--name', 'Ada']
The args module reads this for you, and reading it directly is only
worth it for the simplest of programs.
path_separator
os.path_separator: string
The standard path separator for the current operating system.
exe_path
os.exe_path: string
The full path to the running Zuri executable.
Functions
sleep()
os.sleep(duration: number)
Causes the current thread to sleep for the specified number of seconds.
Parameters
duration(number)
info()
os.info() -> dict
Returns information about the current operation system and machine as a dictionary. The returned dictionary will contain:
sysname: The name of the operating system -nodenameThe name of the current machine -version: The operating system version -release: The release level/version -machine: The hardware/processor type.
Example,
%> os.info()
{sysname: Darwin, nodename: MacBook-Pro.local, version: Darwin Kernel Version
21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101,
release: 21.1.0, machine: arm64}
Returns dict
num_cpus()
os.num_cpus() -> int
The number of logical CPUs available to this process. Useful for sizing
a worker pool: isolate.cpu_count() is the exact same underlying value,
exposed here too so code that only needs this one fact doesn’t have to
import the whole isolate module for it.
Returns int
hostname()
os.hostname() -> string
The current machine’s hostname.
Returns string
Raises Error if the hostname couldn’t be determined.
total_memory()
os.total_memory() -> number
The total physical memory installed on this machine, in bytes.
Returns number
Raises Error if this isn’t supported on the current platform.
free_memory()
os.free_memory() -> number
An estimate of how much physical memory is available for new allocations
right now, in bytes: free memory plus easily reclaimable caches/buffers,
the same figure a tool like free reports as “available” rather than
the smaller, less useful “free” figure alone.
Returns number
Raises Error if this isn’t supported on the current platform.
uptime()
os.uptime() -> number
How long the machine has been running since it last booted, in seconds.
Returns number
Raises Error if this isn’t supported on the current platform.
2021, Richard Ore and Zuri contributors