»Core Development>Code coverage>Mac/Demo/applescript/Disk_Copy/Special_Events.py

Python code coverage for Mac/Demo/applescript/Disk_Copy/Special_Events.py

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