py-cvs-rel2_1 (Rev 1.2) merge
[python/dscho.git] / Mac / Demo / applescript / Disk_Copy / Special_Events.py
bloba98eb8a4228652a0e4f1989671c47cd8665f6883
1 """Suite Special Events: Commands for mounting Disk Copy images
2 Level 1, version 1
4 Generated from Macintosh HD:Hulpprogramma's:Disk Copy
5 AETE/AEUT resource version 1/0, language 0, script 0
6 """
8 import aetools
9 import MacOS
11 _code = 'ddsk'
13 class Special_Events_Events:
15 _argmap_mount = {
16 'access_mode' : 'Acss',
17 'checksum_verification' : 'VChk',
18 'signature_verification' : 'VSig',
19 'RAM_caching' : 'Cach',
22 def mount(self, _object, _attributes={}, **_arguments):
23 """mount: Mounts an Disk Copy image as a disk volume
24 Required argument: a reference to the disk image to be mounted
25 Keyword argument access_mode: the access mode for mounted volume (default is "any", i.e. best possible)
26 Keyword argument checksum_verification: Verify the checksum before mounting?
27 Keyword argument signature_verification: Verify the DigiSignŽ signature before mounting?
28 Keyword argument RAM_caching: Cache the disk image in RAM? (if omitted, don't cache)
29 Keyword argument _attributes: AppleEvent attribute dictionary
30 Returns: a reference to mounted disk
31 """
32 _code = 'ddsk'
33 _subcode = 'Moun'
35 aetools.keysubst(_arguments, self._argmap_mount)
36 _arguments['----'] = _object
38 aetools.enumsubst(_arguments, 'Acss', _Enum_Acss)
39 aetools.enumsubst(_arguments, 'VChk', _Enum_bool)
40 aetools.enumsubst(_arguments, 'VSig', _Enum_bool)
41 aetools.enumsubst(_arguments, 'Cach', _Enum_bool)
43 _reply, _arguments, _attributes = self.send(_code, _subcode,
44 _arguments, _attributes)
45 if _arguments.has_key('errn'):
46 raise aetools.Error, aetools.decodeerror(_arguments)
47 # XXXX Optionally decode result
48 if _arguments.has_key('----'):
49 return _arguments['----']
51 _argmap_execute_DiskScript = {
52 'checksum_verification' : 'VChk',
53 'signature_verification' : 'VSig',
56 def execute_DiskScript(self, _object, _attributes={}, **_arguments):
57 """execute DiskScript: Executes a Disk Copy-specific DiskScript
58 Required argument: a reference to the DiskScript to execute
59 Keyword argument checksum_verification: Should checksums be verified when mounting images referenced in the DiskScript?
60 Keyword argument signature_verification: Should the DigiSignŽ signature of the DiskScript and the images it references be verified?
61 Keyword argument _attributes: AppleEvent attribute dictionary
62 """
63 _code = 'ddsk'
64 _subcode = 'XEQd'
66 aetools.keysubst(_arguments, self._argmap_execute_DiskScript)
67 _arguments['----'] = _object
69 aetools.enumsubst(_arguments, 'VChk', _Enum_bool)
70 aetools.enumsubst(_arguments, 'VSig', _Enum_bool)
72 _reply, _arguments, _attributes = self.send(_code, _subcode,
73 _arguments, _attributes)
74 if _arguments.has_key('errn'):
75 raise aetools.Error, aetools.decodeerror(_arguments)
76 # XXXX Optionally decode result
77 if _arguments.has_key('----'):
78 return _arguments['----']
80 def unmount(self, _object, _attributes={}, **_arguments):
81 """unmount: Unmount and eject (if necessary) a volume
82 Required argument: a reference to disk to be unmounted (and ejected)
83 Keyword argument _attributes: AppleEvent attribute dictionary
84 """
85 _code = 'ddsk'
86 _subcode = 'Umnt'
88 if _arguments: raise TypeError, 'No optional args expected'
89 _arguments['----'] = _object
92 _reply, _arguments, _attributes = self.send(_code, _subcode,
93 _arguments, _attributes)
94 if _arguments.has_key('errn'):
95 raise aetools.Error, aetools.decodeerror(_arguments)
96 # XXXX Optionally decode result
97 if _arguments.has_key('----'):
98 return _arguments['----']
100 _argmap_create = {
101 'saving_as' : 'SvAs',
102 'logical_blocks' : 'Blks',
103 'zeroing' : 'Zero',
104 'leave_image_mounted' : 'Moun',
105 'filesystem' : 'Fsys',
108 def create(self, _object, _attributes={}, **_arguments):
109 """create: Create a new Disk Copy document
110 Required argument: the name of the volume to create
111 Keyword argument saving_as: the disk image to be created
112 Keyword argument logical_blocks: the number of logical blocks
113 Keyword argument zeroing: Should all blocks on the disk be set to zero?
114 Keyword argument leave_image_mounted: Should the image be mounted after it is created?
115 Keyword argument filesystem: file system to use (Mac OS Standard/compatible, Mac OS Enhanced)
116 Keyword argument _attributes: AppleEvent attribute dictionary
117 Returns: a reference to newly created disk image (or newly mounted disk)
119 _code = 'ddsk'
120 _subcode = 'Crea'
122 aetools.keysubst(_arguments, self._argmap_create)
123 _arguments['----'] = _object
125 aetools.enumsubst(_arguments, 'SvAs', _Enum_fss_)
126 aetools.enumsubst(_arguments, 'Blks', _Enum_long)
127 aetools.enumsubst(_arguments, 'Zero', _Enum_bool)
128 aetools.enumsubst(_arguments, 'Moun', _Enum_bool)
129 aetools.enumsubst(_arguments, 'Fsys', _Enum_Fsys)
131 _reply, _arguments, _attributes = self.send(_code, _subcode,
132 _arguments, _attributes)
133 if _arguments.has_key('errn'):
134 raise aetools.Error, aetools.decodeerror(_arguments)
135 # XXXX Optionally decode result
136 if _arguments.has_key('----'):
137 return _arguments['----']
139 def verify_checksum(self, _object, _attributes={}, **_arguments):
140 """verify checksum: Verify the checksum of a Disk Copy 4.2 or a Disk Copy 6.0 read-only document
141 Required argument: the disk image to be verified
142 Keyword argument _attributes: AppleEvent attribute dictionary
143 Returns: the result of the checksum verification
145 _code = 'ddsk'
146 _subcode = 'Vcrc'
148 if _arguments: raise TypeError, 'No optional args expected'
149 _arguments['----'] = _object
152 _reply, _arguments, _attributes = self.send(_code, _subcode,
153 _arguments, _attributes)
154 if _arguments.has_key('errn'):
155 raise aetools.Error, aetools.decodeerror(_arguments)
156 # XXXX Optionally decode result
157 if _arguments.has_key('----'):
158 return _arguments['----']
160 def verify_signature(self, _object, _attributes={}, **_arguments):
161 """verify signature: Verify the DigiSignŽ signature for a Disk Copy document
162 Required argument: the disk image to be verified
163 Keyword argument _attributes: AppleEvent attribute dictionary
164 Returns: Is the DigiSignŽ signature valid?
166 _code = 'ddsk'
167 _subcode = 'Vsig'
169 if _arguments: raise TypeError, 'No optional args expected'
170 _arguments['----'] = _object
173 _reply, _arguments, _attributes = self.send(_code, _subcode,
174 _arguments, _attributes)
175 if _arguments.has_key('errn'):
176 raise aetools.Error, aetools.decodeerror(_arguments)
177 # XXXX Optionally decode result
178 if _arguments.has_key('----'):
179 return _arguments['----']
181 _argmap_sign_image = {
182 'using_signer' : 'Sinr',
185 def sign_image(self, _object, _attributes={}, **_arguments):
186 """sign image: Add a DigiSignŽ signature to a Disk Copy document
187 Required argument: the disk image to be signed
188 Keyword argument using_signer: a reference to signer file to use
189 Keyword argument _attributes: AppleEvent attribute dictionary
191 _code = 'ddsk'
192 _subcode = 'Asig'
194 aetools.keysubst(_arguments, self._argmap_sign_image)
195 _arguments['----'] = _object
197 aetools.enumsubst(_arguments, 'Sinr', _Enum_alis)
199 _reply, _arguments, _attributes = self.send(_code, _subcode,
200 _arguments, _attributes)
201 if _arguments.has_key('errn'):
202 raise aetools.Error, aetools.decodeerror(_arguments)
203 # XXXX Optionally decode result
204 if _arguments.has_key('----'):
205 return _arguments['----']
207 _argmap_create_a_floppy_from = {
208 'signature_verification' : 'VSig',
209 'erase_confirmation' : 'Cfrm',
210 'make_multiple_floppies' : 'Mult',
213 def create_a_floppy_from(self, _object, _attributes={}, **_arguments):
214 """create a floppy from: create a floppy disk from a Disk Copy document
215 Required argument: the disk image to make a floppy from
216 Keyword argument signature_verification: Should the DigiSignŽ signature be verified before creating a floppy disk?
217 Keyword argument erase_confirmation: Should the user be asked to confirm the erasure of the previous contents of floppy disks?
218 Keyword argument make_multiple_floppies: Should the user be prompted to create multiple floppy disks?
219 Keyword argument _attributes: AppleEvent attribute dictionary
221 _code = 'ddsk'
222 _subcode = 'Bfpy'
224 aetools.keysubst(_arguments, self._argmap_create_a_floppy_from)
225 _arguments['----'] = _object
227 aetools.enumsubst(_arguments, 'VSig', _Enum_bool)
228 aetools.enumsubst(_arguments, 'Cfrm', _Enum_bool)
229 aetools.enumsubst(_arguments, 'Mult', _Enum_bool)
231 _reply, _arguments, _attributes = self.send(_code, _subcode,
232 _arguments, _attributes)
233 if _arguments.has_key('errn'):
234 raise aetools.Error, aetools.decodeerror(_arguments)
235 # XXXX Optionally decode result
236 if _arguments.has_key('----'):
237 return _arguments['----']
239 _argmap_check_image = {
240 'details' : 'ChDe',
243 def check_image(self, _object, _attributes={}, **_arguments):
244 """check image: Check the disk imageÕs internal data structures for any inconsistencies. Works on NDIF, Disk Copy 4.2, DARTŽ, or DiskSet images.
245 Required argument: the disk image to be verified
246 Keyword argument details: Should the disk image details be displayed?
247 Keyword argument _attributes: AppleEvent attribute dictionary
248 Returns: a record containing a boolean (true/false) value if the image passes consistency tests, and the numbers of warnings and errors
250 _code = 'ddsk'
251 _subcode = 'Chek'
253 aetools.keysubst(_arguments, self._argmap_check_image)
254 _arguments['----'] = _object
256 aetools.enumsubst(_arguments, 'ChDe', _Enum_bool)
258 _reply, _arguments, _attributes = self.send(_code, _subcode,
259 _arguments, _attributes)
260 if _arguments.has_key('errn'):
261 raise aetools.Error, aetools.decodeerror(_arguments)
262 # XXXX Optionally decode result
263 if _arguments.has_key('----'):
264 return _arguments['----']
266 _argmap_segment_image = {
267 'segment_count' : 'SGCT',
268 'segment_size' : 'SGSZ',
269 'segment_name' : 'SGNM',
270 'image_ID' : 'SGID',
273 def segment_image(self, _object, _attributes={}, **_arguments):
274 """segment image: Segment a NDIF R/W or R/O image into smaller pieces
275 Required argument: the disk image to be segmented
276 Keyword argument segment_count: the number of image segments to create
277 Keyword argument segment_size: the size of image segments (in blocks) to create
278 Keyword argument segment_name: the root name for each image segment file
279 Keyword argument image_ID: string used to generate a unique image ID to group the segments
280 Keyword argument _attributes: AppleEvent attribute dictionary
281 Returns: a list of references to the image segments created
283 _code = 'ddsk'
284 _subcode = 'SGMT'
286 aetools.keysubst(_arguments, self._argmap_segment_image)
287 _arguments['----'] = _object
290 _reply, _arguments, _attributes = self.send(_code, _subcode,
291 _arguments, _attributes)
292 if _arguments.has_key('errn'):
293 raise aetools.Error, aetools.decodeerror(_arguments)
294 # XXXX Optionally decode result
295 if _arguments.has_key('----'):
296 return _arguments['----']
298 _argmap_create_SMI = {
299 'source_images' : 'SMI1',
300 'launching_application' : 'SMI2',
301 'launching_document' : 'SMI3',
302 'version_string' : 'SMI4',
303 'checksum_verification' : 'VChk',
304 'signature_verification' : 'VSig',
305 'image_signing' : 'SImg',
308 def create_SMI(self, _object, _attributes={}, **_arguments):
309 """create SMI: Creates a self-mounting image (SMI) from a list of NDIF disk images
310 Required argument: the self-mounting image to create
311 Keyword argument source_images: a list of references to sources images
312 Keyword argument launching_application: the path to an application to launch
313 Keyword argument launching_document: the path to a document to open
314 Keyword argument version_string: sets the 'vers' 1 resource of the self-mounting image
315 Keyword argument checksum_verification: Should the checksum of the source images be verified before creating the SMI?
316 Keyword argument signature_verification: Should the DigiSignŽ signature of the source images be verified before creating the SMI?
317 Keyword argument image_signing: Should the SMI be given a digital signature when it is created?
318 Keyword argument _attributes: AppleEvent attribute dictionary
319 Returns: a reference to the self-mounting image created
321 _code = 'ddsk'
322 _subcode = 'MSMI'
324 aetools.keysubst(_arguments, self._argmap_create_SMI)
325 _arguments['----'] = _object
327 aetools.enumsubst(_arguments, 'VChk', _Enum_bool)
328 aetools.enumsubst(_arguments, 'VSig', _Enum_bool)
329 aetools.enumsubst(_arguments, 'SImg', _Enum_bool)
331 _reply, _arguments, _attributes = self.send(_code, _subcode,
332 _arguments, _attributes)
333 if _arguments.has_key('errn'):
334 raise aetools.Error, aetools.decodeerror(_arguments)
335 # XXXX Optionally decode result
336 if _arguments.has_key('----'):
337 return _arguments['----']
340 class Verify_Checksum_reply_record(aetools.ComponentItem):
341 """Verify Checksum reply record - """
342 want = 'Rcrc'
343 class validity(aetools.NProperty):
344 """validity - true if checksum is valid """
345 which = 'Vlid'
346 want = 'bool'
347 class expected_checksum(aetools.NProperty):
348 """expected checksum - checksum value stored in the image header (in hexadecimal) """
349 which = 'crcE'
350 want = 'TEXT'
351 class calculated_checksum(aetools.NProperty):
352 """calculated checksum - checksum value actually calculated (in hexadecimal) """
353 which = 'crcA'
354 want = 'TEXT'
356 class Check_Image_reply_record(aetools.ComponentItem):
357 """Check Image reply record - """
358 want = 'Rchk'
359 class consistency(aetools.NProperty):
360 """consistency - Does the image pass consistency checks? """
361 which = 'Rch1'
362 want = 'bool'
363 class error_count(aetools.NProperty):
364 """error count - the number of errors recorded """
365 which = 'Rch2'
366 want = 'long'
367 class warning_count(aetools.NProperty):
368 """warning count - the number of warnings recorded """
369 which = 'Rch3'
370 want = 'long'
371 Verify_Checksum_reply_record._propdict = {
372 'validity' : validity,
373 'expected_checksum' : expected_checksum,
374 'calculated_checksum' : calculated_checksum,
376 Verify_Checksum_reply_record._elemdict = {
378 Check_Image_reply_record._propdict = {
379 'consistency' : consistency,
380 'error_count' : error_count,
381 'warning_count' : warning_count,
383 Check_Image_reply_record._elemdict = {
385 _Enum_Acss = {
386 'read_and_write' : 'RdWr', # read/write access
387 'read_only' : 'Rdxx', # read-only access
388 'any' : 'Anyx', # best possible access
391 _Enum_Fsys = {
392 'Mac_OS_Standard' : 'Fhfs', # classic HFS file system
393 'compatible_Mac_OS_Extended' : 'Fhf+', # new HFS+ file system
396 _Enum_alis = None # XXXX enum alis not found!!
397 _Enum_fss_ = None # XXXX enum fss not found!!
398 _Enum_long = None # XXXX enum long not found!!
399 _Enum_bool = None # XXXX enum bool not found!!
402 # Indices of types declared in this module
404 _classdeclarations = {
405 'Rchk' : Check_Image_reply_record,
406 'Rcrc' : Verify_Checksum_reply_record,
409 _propdeclarations = {
410 'crcE' : expected_checksum,
411 'Rch2' : error_count,
412 'crcA' : calculated_checksum,
413 'Rch3' : warning_count,
414 'Vlid' : validity,
415 'Rch1' : consistency,
418 _compdeclarations = {
421 _enumdeclarations = {
422 'Acss' : _Enum_Acss,
423 'Fsys' : _Enum_Fsys,