@@ -249,13 +249,27 | |||||
249 | destination.write(chunk) |
|
249 | destination.write(chunk) | |
250 | destination.close() |
|
250 | destination.close() | |
251 | f = open('/tmp/'+txtFilename.name, 'r') |
|
251 | f = open('/tmp/'+txtFilename.name, 'r') | |
252 |
|
|
252 | newContent = f.readlines() | |
253 | #for line in f: |
|
|||
254 | # lsLine = line.readline() |
|
|||
255 | f.close() |
|
253 | f.close() | |
256 |
|
|
254 | content = "" | |
|
255 | for i,line in enumerate(newContent): | |||
|
256 | if i == 0: | |||
|
257 | newLine = line.replace("'","") | |||
|
258 | pos = newLine.find("=") | |||
|
259 | expName = newLine[pos+1:].strip() | |||
|
260 | elif i == 2: | |||
|
261 | pos = line.find("=") | |||
|
262 | num_patterns = line[pos+1:].strip() | |||
|
263 | else: | |||
|
264 | content += line | |||
|
265 | ||||
257 | else: |
|
266 | else: | |
258 | txtFilename = "Error" |
|
267 | txtFilename = "Error" | |
259 | content = "Error" |
|
268 | content = "Error" | |
260 | return render_to_response('abscontrol/upload.html', {'txtFilename': txtFilename, 'content' : content}) |
|
269 | expName = "" | |
261 |
|
270 | num_patterns = 0 | ||
|
271 | ||||
|
272 | return render_to_response('abscontrol/upload.html', {'txtFilename': txtFilename, 'content' : content, | |||
|
273 | 'expName' : expName, 'num_patterns' : num_patterns, | |||
|
274 | }) | |||
|
275 |
@@ -9,7 +9,11 | |||||
9 | <label for="lblFilename">{{ txtFilename }}</label> |
|
9 | <label for="lblFilename">{{ txtFilename }}</label> | |
10 | </div> |
|
10 | </div> | |
11 | <div class="divUes"> |
|
11 | <div class="divUes"> | |
12 |
<label for="lbl |
|
12 | <label for="lblExperiment">Experiment:</label> | |
|
13 | <p>{{ expName }}</p> | |||
|
14 | <label for="lblNumber">Number of patterns:</label> | |||
|
15 | <p>{{ num_patterns }}</p> | |||
|
16 | <label for="lblContent">Content:</label> | |||
13 | <p>{{ content }}</p> |
|
17 | <p>{{ content }}</p> | |
14 | </div> |
|
18 | </div> | |
15 | </div> |
|
19 | </div> |
@@ -11,10 +11,36 | |||||
11 |
|
11 | |||
12 | def __init__(self, filename): |
|
12 | def __init__(self, filename): | |
13 | self.fileName = filename |
|
13 | self.fileName = filename | |
|
14 | self.content = "" | |||
|
15 | self.exp_name = "" | |||
|
16 | self.number_patterns = 0 | |||
|
17 | self.patterns = {} | |||
|
18 | ||||
|
19 | def readFile(self, path): | |||
|
20 | f = open(path, 'r') | |||
|
21 | self.content = f.readlines() | |||
|
22 | f.close() | |||
14 |
|
23 | |||
15 |
def |
|
24 | def getMetadata(self): | |
16 | destination = open(self.fileName, 'wb+') |
|
25 | newLine = self.content[0].replace("'","") | |
|
26 | pos = newLine.find("=") | |||
|
27 | self.exp_name = newLine[pos+1:].strip() | |||
17 |
|
28 | |||
18 | destination.close() |
|
29 | pos = self.content[2].find("=") | |
|
30 | self.number_patterns = int(self.content[2][pos+1:].strip()) | |||
|
31 | ||||
|
32 | self.patterns = self.getPatterns(self.content[3:]) | |||
19 |
|
33 | |||
20 | No newline at end of file |
|
34 | def getPatterns(self, content): | |
|
35 | lsPattern = [] | |||
|
36 | index = 8 | |||
|
37 | ||||
|
38 | for i in range(0, self.number_patterns): | |||
|
39 | first = i+index | |||
|
40 | second = first+index | |||
|
41 | antennaUp = content[i:first] | |||
|
42 | antennaDown = content[first+1:second] | |||
|
43 | dicPattern = {"number" : content[i], "up" : antennaUp, "down" : antennaDown} | |||
|
44 | lsPattern.append(dicPattern) | |||
|
45 | ||||
|
46 | return lsPattern No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now