author | William Roberts <williamr@symbian.org> |
Tue, 29 Jun 2010 17:58:44 +0100 | |
changeset 300 | 3b8bce67b574 |
parent 189 | 0d02b2df4cbb |
child 200 | 12422144aae1 |
permissions | -rw-r--r-- |
179
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
1 |
# Copyright (c) 2009 Symbian Foundation Ltd |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
2 |
# This component and the accompanying materials are made available |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
3 |
# under the terms of the License "Eclipse Public License v1.0" |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
4 |
# which accompanies this distribution, and is available |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
5 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
6 |
# |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
7 |
# Initial Contributors: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
8 |
# Symbian Foundation Ltd - initial contribution. |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
9 |
# |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
10 |
# Contributors: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
11 |
# mattd <mattd@symbian.org> |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
12 |
# |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
13 |
# Description: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
14 |
# DBRutils - Module for handling little bits of stuff to do with generating hashes and scaning directories |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
15 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
16 |
import re |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
17 |
import os |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
18 |
import sys |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
19 |
import string |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
20 |
from os.path import join, isfile, stat |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
21 |
from stat import * |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
22 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
23 |
import glob # temporary (I hope) used for grabbing stuf from zip files... |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
24 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
25 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
26 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
27 |
def defaultdb(): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
28 |
return os.path.join(patchpath(),'baseline.db') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
29 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
30 |
def patchpath(): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
31 |
return os.path.join(epocroot(),'%s/' % patch_path_internal()) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
32 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
33 |
def patch_path_internal(): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
34 |
return 'epoc32/relinfo' |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
35 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
36 |
def exclude_dirs(): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
37 |
fixpath = re.compile('\\\\') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
38 |
leadingslash = re.compile('^%s' % fixpath.sub('/',epocroot())) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
39 |
return [string.lower(leadingslash.sub('',fixpath.sub('/',os.path.join(epocroot(),'epoc32/build')))),string.lower(leadingslash.sub('',fixpath.sub('/',patch_path_internal())))] |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
40 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
41 |
def exclude_files(): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
42 |
# return ['\.sym$','\.dll$'] # just testing... |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
43 |
return ['\.sym$'] |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
44 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
45 |
def epocroot(): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
46 |
return os.environ.get('EPOCROOT') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
47 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
48 |
def scanenv(): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
49 |
print 'Scanning local environment' |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
50 |
directory = os.path.join(epocroot(),'epoc32') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
51 |
env = scandir(directory, exclude_dirs(), exclude_files()) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
52 |
return env |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
53 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
54 |
def createzip(files, name): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
55 |
tmpfilename = os.tmpnam( ) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
56 |
print tmpfilename |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
57 |
f = open(tmpfilename,'w') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
58 |
for file in sorted(files): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
59 |
str = '%s%s' % (file,'\n') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
60 |
f.write(str) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
61 |
f.close() |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
62 |
os.chdir(epocroot()) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
63 |
exestr = '7z a -Tzip -i@%s %s' %(tmpfilename,name) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
64 |
print 'executing: >%s<\n' %exestr |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
65 |
os.system(exestr) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
66 |
os.unlink(tmpfilename) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
67 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
68 |
def extractfiles(files, path): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
69 |
zips = glob.glob(os.path.join(path, '*.zip')) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
70 |
for name in zips: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
71 |
extractfromzip(files, name) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
72 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
73 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
74 |
def extractfromzip(files, name): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
75 |
tmpfilename = os.tmpnam( ) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
76 |
print tmpfilename |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
77 |
os.chdir(epocroot()) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
78 |
f = open(tmpfilename,'w') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
79 |
for file in sorted(files): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
80 |
str = '%s%s' % (file,'\n') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
81 |
f.write(str) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
82 |
f.close() |
189
0d02b2df4cbb
DBRTools - piped the unzip output to null so that cleanenv isn't as noisy.
MattD <mattd@symbian.org>
parents:
179
diff
changeset
|
83 |
exestr = '7z x -y -i@%s %s >nul' %(tmpfilename,name) |
0d02b2df4cbb
DBRTools - piped the unzip output to null so that cleanenv isn't as noisy.
MattD <mattd@symbian.org>
parents:
179
diff
changeset
|
84 |
# exestr = '7z x -y -i@%s %s' %(tmpfilename,name) |
179
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
85 |
print 'executing: >%s<\n' %exestr |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
86 |
os.system(exestr) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
87 |
os.unlink(tmpfilename) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
88 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
89 |
def deletefiles(files): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
90 |
os.chdir(epocroot()) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
91 |
for file in files: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
92 |
print 'deleting %s' %file |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
93 |
os.unlink(file) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
94 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
95 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
96 |
def generateMD5s(testset): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
97 |
db = dict() |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
98 |
if(len(testset)): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
99 |
# print testset |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
100 |
os.chdir(epocroot()) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
101 |
tmpfilename = os.tmpnam( ) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
102 |
print tmpfilename, '\n' |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
103 |
f = open(tmpfilename,'w') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
104 |
for file in testset: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
105 |
entry = dict() |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
106 |
entry['md5'] = 'xxx' |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
107 |
db[file] = entry |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
108 |
str = '%s%s' % (file,'\n') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
109 |
f.write(str) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
110 |
f.close() |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
111 |
outputfile = os.tmpnam() |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
112 |
exestr = 'evalid -f %s %s %s' % (tmpfilename, epocroot(), outputfile) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
113 |
# print exestr |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
114 |
exeresult = os.system(exestr) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
115 |
if(exeresult): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
116 |
sys.exit('Fatal error executing: %s\nReported error: %s' % (exestr,os.strerror(exeresult))) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
117 |
else: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
118 |
db = gethashes(db,outputfile) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
119 |
os.unlink(outputfile) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
120 |
os.unlink(tmpfilename) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
121 |
return db |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
122 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
123 |
# Brittle and nasty!!! |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
124 |
def gethashes(db,md5filename): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
125 |
os.chdir(epocroot()) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
126 |
# print 'trying to open %s' % md5filename |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
127 |
file = open(md5filename,'r') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
128 |
root = '' |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
129 |
fixpath = re.compile('\\\\') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
130 |
leadingslash = re.compile('^%s' % fixpath.sub('/',epocroot())) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
131 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
132 |
evalidparse = re.compile('(.+)\sTYPE=(.+)\sMD5=(.+)') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
133 |
dirparse = re.compile('Directory:(\S+)') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
134 |
for line in file: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
135 |
res = evalidparse.match(line) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
136 |
if(res): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
137 |
filename = "%s%s" % (root,res.group(1)) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
138 |
filename = string.lower(fixpath.sub('/',leadingslash.sub('',filename))) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
139 |
# print "found %s" % filename |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
140 |
if(filename in db): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
141 |
db[filename]['md5'] = res.group(3) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
142 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
143 |
else: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
144 |
res = dirparse.match(line) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
145 |
if(res): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
146 |
if(res.group(1) == '.'): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
147 |
root = '' |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
148 |
else: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
149 |
root = '%s/' % res.group(1) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
150 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
151 |
file.close() |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
152 |
return db |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
153 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
154 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
155 |
def scandir(top, exclude_dirs, exclude_files): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
156 |
# exclude_dirs must be in lower case... |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
157 |
# print "Remember to expand the logged dir from", top, "!!!" |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
158 |
countdown = 0 |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
159 |
env = dict() |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
160 |
fixpath = re.compile('\\\\') |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
161 |
leadingslash = re.compile('^%s' % fixpath.sub('/',epocroot())) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
162 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
163 |
ignorestr='' |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
164 |
for exclude in exclude_files: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
165 |
if(len(ignorestr)): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
166 |
ignorestr = '%s|%s' % (ignorestr, exclude) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
167 |
else: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
168 |
ignorestr = exclude |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
169 |
ignore = re.compile(ignorestr) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
170 |
|
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
171 |
for root, dirs, files in os.walk(top, topdown=True): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
172 |
for dirname in dirs: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
173 |
# print string.lower(leadingslash.sub('',fixpath.sub('/',os.path.join(root,dirname)))) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
174 |
if(string.lower(leadingslash.sub('',fixpath.sub('/',os.path.join(root,dirname)))) in exclude_dirs): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
175 |
# print 'removing: %s' % os.path.join(root,dirname) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
176 |
dirs.remove(dirname) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
177 |
for name in files: |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
178 |
filename = os.path.join(root, name) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
179 |
statinfo = os.stat(filename) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
180 |
fn = string.lower(leadingslash.sub('',fixpath.sub('/',filename))) |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
181 |
# print '%s\t%s' % (filename, fn); |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
182 |
if(countdown == 0): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
183 |
print '.', |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
184 |
countdown = 1000 |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
185 |
countdown = countdown-1 |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
186 |
if not ignore.search(fn,1): |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
187 |
entry = dict() |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
188 |
entry['time'] = '%d' % statinfo[ST_MTIME] |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
189 |
entry['size'] = '%d' % statinfo[ST_SIZE] |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
190 |
entry['md5'] = 'xxx' |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
191 |
env[fn] = entry |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
192 |
# data = [statinfo[ST_MTIME],statinfo[ST_SIZE],'xxx'] |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
193 |
# env[fn] = data |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
194 |
print '\n' |
eab8a264a833
Pulled the DBRTools from their own repo and popped them into this one. Still very much a 'work in progress'.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
195 |
return env |