Copyright (c) Hyperion Entertainment and contributors.
Difference between revisions of "AmigaOS Manual: Python Modules and Packages"
(Added function parameters) |
(Added function parameters) |
||
Line 262: | Line 262: | ||
=== AddChooser() === |
=== AddChooser() === |
||
+ | |||
+ | AddChooser( label, choices, weight, selected, mode, onclick ) |
||
+ | |||
=== AddLabel() === |
=== AddLabel() === |
||
=== AddPackage() === |
=== AddPackage() === |
Revision as of 01:59, 26 June 2019
Contents
- 1 Amiga Specific Modules
- 1.1 amiga
- 1.1.1 abort()
- 1.1.2 access()
- 1.1.3 chdir()
- 1.1.4 chmod()
- 1.1.5 chown()
- 1.1.6 close()
- 1.1.7 dup()
- 1.1.8 dup2()
- 1.1.9 fdopen()
- 1.1.10 fstat()
- 1.1.11 ftruncate()
- 1.1.12 getcpu()
- 1.1.13 getcwd()
- 1.1.14 getcwdu()
- 1.1.15 getmachine()
- 1.1.16 getpid()
- 1.1.17 getports()
- 1.1.18 isatty()
- 1.1.19 kill()
- 1.1.20 link()
- 1.1.21 listdir()
- 1.1.22 lseek()
- 1.1.23 lstat()
- 1.1.24 mkdir()
- 1.1.25 open()
- 1.1.26 pipe()
- 1.1.27 popen()
- 1.1.28 putenv()
- 1.1.29 read()
- 1.1.30 remove()
- 1.1.31 rename()
- 1.1.32 rmdir()
- 1.1.33 stat()
- 1.1.34 stat_float_times()
- 1.1.35 strerror()
- 1.1.36 system()
- 1.1.37 tempnam()
- 1.1.38 tmpfile()
- 1.1.39 tmpnam()
- 1.1.40 umask()
- 1.1.41 unlink()
- 1.1.42 urandom()
- 1.1.43 utime()
- 1.1.44 waitforport()
- 1.1.45 write()
- 1.2 arexx
- 1.3 asl
- 1.4 catalog
- 1.5 icon
- 1.6 installer
- 1.6.1 AddButton()
- 1.6.2 AddCheckBox()
- 1.6.3 AddChooser()
- 1.6.4 AddLabel()
- 1.6.5 AddPackage()
- 1.6.6 AddPostInstallAction()
- 1.6.7 AddRadioButton()
- 1.6.8 AddSpace()
- 1.6.9 AddString()
- 1.6.10 BeginGroup()
- 1.6.11 EndGUI()
- 1.6.12 EndGroup()
- 1.6.13 GetDeviceList()
- 1.6.14 GetInteger()
- 1.6.15 GetObject()
- 1.6.16 GetString()
- 1.6.17 GetUIAttr()
- 1.6.18 GotoPage()
- 1.6.19 IsPackageSelected()
- 1.6.20 NewPage()
- 1.6.21 RunInstaller()
- 1.6.22 SelectPackage()
- 1.6.23 SetInteger()
- 1.6.24 SetObject()
- 1.6.25 SetPackageOption()
- 1.6.26 SetString()
- 1.6.27 SetUIAttr()
- 1.6.28 StartGUI()
- 1.1 amiga
- 2 Amiga Specific Packages
Amiga Specific Modules
Amiga Python contains six Amiga specific modules:
- amiga - provides access to the most common system calls
- arexx - support for ARexx communication and ARexx hosts
- asl - provides access to the requesters
- catalog - provides access to the localization functions
- icon - provides access to the icon functions
- installer - provides access to the Installation Utility functions
amiga
This module provides access to AmigaOS system functionality.
abort()
abort ()
Abort the interpreter immediately. Calling the function fails in the hardest way possible on the hosting operating system. This function does not return!
access()
have_access = access ( path, mode )
Use the real uid (User Identifier) or gid (Group Identifier) to test for access to a path. Note that most operations will use the effective uid/gid, therefore this routine can be used in a suid (Set Owner User ID) or sgid (Set Group ID) environment to test if the invoking user has the specified access to the path.
The mode argument can be F_OK to test existence, or the inclusive-OR of R_OK, W_OK, and X_OK.
Access() returns True if access is allowed, False if not.
chdir()
chdir ( path )
Change the current working directory to the specified path.
chmod()
chmod ( path, mode )
Change the access permissions of a file.
chown()
chown ( path, uid, gid )
Change the owner and group id of path to the numeric uid and gid.
close()
close ( fd )
Close a file descriptor (for low level I/O).
dup()
fd2 = dup ( fd )
Return a duplicate of a file descriptor.
dup2()
dup2 ( old_fd, new_fd )
Duplicate file descriptor.
fdopen()
file_object = fdopen ( fd [, mode = 'r' [, bufsize ] ] )
Return an open file object connected to a file descriptor.
fstat()
result = fstat ( fd )
Like stat(), but for an open file descriptor.
ftruncate()
ftruncate ( fd, length )
Truncate a file to a specified length.
getcpu()
getcpu ()
Get the CPU model string.
getcwd()
path = getcwd ()
Return a string representing the current working directory.
getcwdu()
path = getcwdu ()
Return a unicode string representing the current working directory.
getmachine()
getmachine ()
Get the machine model string.
getpid()
pid = getpid ()
Return the current process ID.
getports()
list_of_strings = getports ()
Returns a list of public message port names.
isatty()
bool = isatty ( fd )
Return True if the file descriptor 'fd' is an open file descriptor connected to the slave end of a terminal.
kill()
kill ( pid, sig )
Kill a process 'pid' with a signal 'sig'.
link()
listdir()
lseek()
lstat()
mkdir()
open()
pipe()
popen()
putenv()
read()
remove()
rename()
rmdir()
stat()
stat_float_times()
strerror()
system()
tempnam()
tmpfile()
tmpnam()
umask()
unlink()
urandom()
utime()
waitforport()
write()
arexx
Msg()
Port()
dorexx()
Variables
- __doc__
- __file__
- __name__
asl
This module contains AmigaOS-specific requester function for file and path queries, message boxes, ans similar aspects.
FileRequest()
drawer, file = FileRequest ( title, drawer, filename, pattern )
Opens a file select requester with the given title, the drawer and filename gadgets predefined by drawer and title. If a pattern is given, a pattern gadget is also displayed and pre-set with the given pattern. The result is a tuple drawer, filename which relects the choice of the user.
- Example
Opens up a file requester in T: with 'my.log' as a default name, and a filter set to '#?.log':
drawer, file = asl.FileRequest('Python File Request', 'T:', 'my.log', '#?.log' )
MessageBox()
result = MessageBox( title, body_text, buttons )
Opens a message box with the given title and body text. The options on the dialog are taken from the 'buttons' argument. The 'buttons' string contains individual substrings separated by a '|'.
The result of this function is the button number selected by the user. Numbering starts from left with 1, 2 and so on, but the final button is 0.
- Example
Puts up a requester asking for a 'Yes' or 'No' answer:
result = asl.MessageBox('Python Request', 'AmigaOS rules', 'Yes|No')
Selecting 'Yes' returns 1 and selecting 'No' returns 0.
Variables
- __doc__
- __file__
- __name__
catalog
This module allows you to read Amiga catalog files and retrieve localized string from them.
OpenCatalog()
GetString()
icon
The icon module allows you to manipulate the information stored in the Amiga icon files.
DiskObject()
disk_object = DiskObject( path )
Opens an icon file. The path argument is a path to the icon file to be opened without the icon file extension ".info". On success, the DiskObject method will return a "DiskObject" object which contains the following attributes:
Attribute | Description |
---|---|
tooltypes | Icon tool types |
deftool | The default tool |
stacksize | Program stack size |
Attributes can be manipulated and saved back to the icon using the PutIcon() method.
- Example
Open the "SYS:System/Shell" icon file ("SYS:System/Shell.info") and print its attributes.
import icon # Include icon module ic = icon.DiskObject( 'SYS:System/Shell' ) print( 'Tool types: ' + str( ic.tooltypes ) ) print( 'Default tool: ' + ic.deftool ) print( 'Stack size: ' + str( ic.stacksize ) )
PutIcon()
installer
The installer module provides an interface to the Installation Utility. The provided functions allow you to create an installation script with a graphical user interface.
AddButton()
AddButton( label, frame, weight, onclick )
AddCheckBox()
AddCheckBox( label, weight, checked, onclick )
AddChooser()
AddChooser( label, choices, weight, selected, mode, onclick )
AddLabel()
AddPackage()
AddPostInstallAction()
AddRadioButton()
AddSpace()
AddString()
BeginGroup()
EndGUI()
EndGroup()
GetDeviceList()
GetInteger()
GetObject()
GetString()
GetUIAttr()
GotoPage()
IsPackageSelected()
NewPage()
RunInstaller()
SelectPackage()
SetInteger()
SetObject()
SetPackageOption()
SetString()
SetUIAttr()
StartGUI()
Amiga Specific Packages
The current Amiga Python release does not contain any Amiga specific packages.