File: check_libsndfile.py

package info (click to toggle)
libsndfile 0.0.26-1.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,940 kB
  • ctags: 1,705
  • sloc: ansic: 20,078; sh: 8,623; makefile: 205; python: 47
file content (67 lines) | stat: -rwxr-xr-x 1,436 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python 

import commands, os, string, sys 

# This program tests libsndfile against a user provided list of audio files. 
# The list is provided as a text file. 
# 

_EXE_NAME = 'examples/sndfile_info'


def dump_status_output_exit (status, output, msg = None): 
	if msg: 
		print msg 
	print "Status :", status 
	print output 
	sys.exit (0) 

def sfinfo_check_ok (filename): 
	cmd = '%s %s' % (_EXE_NAME, filename) 
	(status, output) = commands.getstatusoutput (cmd) 
	if status: 
		dump_status_output_exit (status, output, "Bad status. Dumping") 
	if string.find (output, "should") > 0: 
		dump_status_output_exit (status, output, "Found `should'. Dumping") 
	if string.find (output, "*") > 0: 
		dump_status_output_exit (status, output, "Found `*'. Dumping") 
	return 

def sfinfo_check_not_crash (filename): 
	print filename 
	 
_USAGE = """ 
This is the usage message. 

""" 

if len (sys.argv) != 2: 
	print _USAGE 
	sys.exit (0) 


if not os.path.isfile (_EXE_NAME): 
	print "Could not find required program :", _EXE_NAME 
	sys.exit (0) 

list_file = open (sys.argv [1]) 

while 1: 
	line = list_file.readline () 
	if not line: 
		break  
	line = string.strip (line)
	if len (line) < 1:
		continue 
	if line [0] == '#':
		continue 
	print line
	if os.path.isfile (line): 
		sfinfo_check_ok (line) 
	else: 
		print "Bad file name : ", line 
		sys.exit (0) 

list_file.close () 

print "Finished. No errors found."