# SVN changeset patch # User jsalyrosas # Date 2013-05-06 22:12:03.916544 # Revision 151 - Implementando la lectura del archivo ABS, para obtener el experimento, el numero y el valor de los patrones de configuracion de la antena. Index: trunk/webapp/abscontrol/views.py =================================================================== diff --git a/trunk/webapp/abscontrol/views.py b/trunk/webapp/abscontrol/views.py --- a/trunk/webapp/abscontrol/views.py (revision 150) +++ b/trunk/webapp/abscontrol/views.py (revision 151) @@ -249,13 +249,27 @@ destination.write(chunk) destination.close() f = open('/tmp/'+txtFilename.name, 'r') - content = f.read() - #for line in f: - # lsLine = line.readline() + newContent = f.readlines() f.close() - #content = lsLine + content = "" + for i,line in enumerate(newContent): + if i == 0: + newLine = line.replace("'","") + pos = newLine.find("=") + expName = newLine[pos+1:].strip() + elif i == 2: + pos = line.find("=") + num_patterns = line[pos+1:].strip() + else: + content += line + else: txtFilename = "Error" content = "Error" - return render_to_response('abscontrol/upload.html', {'txtFilename': txtFilename, 'content' : content}) - + expName = "" + num_patterns = 0 + + return render_to_response('abscontrol/upload.html', {'txtFilename': txtFilename, 'content' : content, + 'expName' : expName, 'num_patterns' : num_patterns, + }) + Index: trunk/webapp/templates/abscontrol/upload.html =================================================================== diff --git a/trunk/webapp/templates/abscontrol/upload.html b/trunk/webapp/templates/abscontrol/upload.html --- a/trunk/webapp/templates/abscontrol/upload.html (revision 150) +++ b/trunk/webapp/templates/abscontrol/upload.html (revision 151) @@ -9,7 +9,11 @@
- + +

{{ expName }}

+ +

{{ num_patterns }}

+

{{ content }}

Index: trunk/webapp/util/readABSFile.py =================================================================== diff --git a/trunk/webapp/util/readABSFile.py b/trunk/webapp/util/readABSFile.py --- a/trunk/webapp/util/readABSFile.py (revision 150) +++ b/trunk/webapp/util/readABSFile.py (revision 151) @@ -11,10 +11,36 @@ def __init__(self, filename): self.fileName = filename + self.content = "" + self.exp_name = "" + self.number_patterns = 0 + self.patterns = {} + + def readFile(self, path): + f = open(path, 'r') + self.content = f.readlines() + f.close() - def readFile(self): - destination = open(self.fileName, 'wb+') + def getMetadata(self): + newLine = self.content[0].replace("'","") + pos = newLine.find("=") + self.exp_name = newLine[pos+1:].strip() - destination.close() + pos = self.content[2].find("=") + self.number_patterns = int(self.content[2][pos+1:].strip()) + + self.patterns = self.getPatterns(self.content[3:]) - \ No newline at end of file + def getPatterns(self, content): + lsPattern = [] + index = 8 + + for i in range(0, self.number_patterns): + first = i+index + second = first+index + antennaUp = content[i:first] + antennaDown = content[first+1:second] + dicPattern = {"number" : content[i], "up" : antennaUp, "down" : antennaDown} + lsPattern.append(dicPattern) + + return lsPattern \ No newline at end of file