##// END OF EJS Templates
- Finalizada la funcion que lee(importa) un archivo ABS sin guardarlo a la base de datos....
jsalyrosas -
r152:153
parent child
Show More
@@ -53,9 +53,10
53
53
54 pattern = models.ForeignKey(Pattern)
54 pattern = models.ForeignKey(Pattern)
55 value = models.TextField()
55 value = models.TextField()
56 tx = models.TextField()
56 tx = models.TextField(null=True)
57 rx = models.TextField()
57 rx = models.TextField(null=True)
58 ues = models.CharField(max_length=120)
58 ues = models.CharField(max_length=120, null=True)
59 only_rx = models.PositiveSmallIntegerField(default=0)
59 date_create = models.DateTimeField()
60 date_create = models.DateTimeField()
60 date_modified = models.DateTimeField(null=True)
61 date_modified = models.DateTimeField(null=True)
61 hits = models.PositiveIntegerField()
62 hits = models.PositiveIntegerField()
@@ -81,9 +82,10
81
82
82 pattern = models.ForeignKey(Pattern)
83 pattern = models.ForeignKey(Pattern)
83 value = models.TextField()
84 value = models.TextField()
84 tx = models.TextField()
85 tx = models.TextField(null=True)
85 rx = models.TextField()
86 rx = models.TextField(null=True)
86 ues = models.CharField(max_length=120)
87 ues = models.CharField(max_length=120, null=True)
88 only_rx = models.PositiveSmallIntegerField(default=0)
87 date_create = models.DateTimeField()
89 date_create = models.DateTimeField()
88 date_modified = models.DateTimeField(null=True)
90 date_modified = models.DateTimeField(null=True)
89 hits = models.PositiveIntegerField()
91 hits = models.PositiveIntegerField()
@@ -252,23 +252,6
252 filename = '/tmp/'+txtFilename.name
252 filename = '/tmp/'+txtFilename.name
253 readFile = readABSFile(filename)
253 readFile = readABSFile(filename)
254 expName, num_patterns, patterns = readFile.getMetadata()
254 expName, num_patterns, patterns = readFile.getMetadata()
255
256 '''
257 f = open('/tmp/'+txtFilename.name, 'r')
258 newContent = f.readlines()
259 f.close()
260 content = ""
261 for i,line in enumerate(newContent):
262 if i == 0:
263 newLine = line.replace("'","")
264 pos = newLine.find("=")
265 expName = newLine[pos+1:].strip()
266 elif i == 2:
267 pos = line.find("=")
268 num_patterns = line[pos+1:].strip()
269 else:
270 content += line
271 '''
272 else:
255 else:
273 txtFilename = "Error"
256 txtFilename = "Error"
274 #content = "Error"
257 #content = "Error"
@@ -6,7 +6,7
6 * font-family: 'Roboto Condensed', sans-serif;
6 * font-family: 'Roboto Condensed', sans-serif;
7 */
7 */
8
8
9 body { font-size: 11px; }
9 body { font-size: 12px; }
10 header {border: 1px solid #fcc; font-size: 2em; height: 50px; text-align: center; line-height: 50px}
10 header {border: 1px solid #fcc; font-size: 2em; height: 50px; text-align: center; line-height: 50px}
11 #schema {margin: 0 auto; width: 980px; border: 1px solid #f00; padding: 10px 10px 10px 10px}
11 #schema {margin: 0 auto; width: 980px; border: 1px solid #f00; padding: 10px 10px 10px 10px}
12 #content {border: 1px solid #1cc; margin-top: 5px; margin-bottom: 5px}
12 #content {border: 1px solid #1cc; margin-top: 5px; margin-bottom: 5px}
@@ -44,19 +44,19
44 /****************************************************************************************/
44 /****************************************************************************************/
45 #divProfile { border: 0px solid #dff; margin: 10px 0px; padding: 10px 10px; width: 500px }
45 #divProfile { border: 0px solid #dff; margin: 10px 0px; padding: 10px 10px; width: 500px }
46 .flsAntenna { margin: 10px 0px; width: 750px; padding: 10px 10px }
46 .flsAntenna { margin: 10px 0px; width: 750px; padding: 10px 10px }
47 #divPattern textarea,input[type=text],label{ font-family: Monaco; font-size: inherit; }
47 #divPattern textarea,input[type=text],label{ font-family: "Open Sans"; font-size: inherit; }
48
48
49 #divPattern textarea {resize: none; overflow: hidden}
49 #divPattern textarea {resize: none; overflow: hidden}
50
50
51 .divAntenna { float: left; margin: 10px; height: 160px; border: 0px solid #fcc !important; width: 260px }
51 .divAntenna { float: left; margin: 10px; height: 160px; border: 0px solid #fcc !important; width: 260px }
52 .divAntenna label{ display: block }
52 .divAntenna label{ display: block }
53 .txtAntenna { max-width: 250px; max-height: 125px; width: 250px; height: 125px }
53 .txtAntenna { width: 250px; max-width: 250px; height: 135px; max-height: 140px; }
54 .divAntenna p{ max-width: 250px; max-height: 125px; width: 250px; height: 125px }
54 .divAntenna p{ width: 250px; max-width: 250px; height: 130px; max-height: 130px; border: 1px solid #eee !important}
55
55
56 .divTx { display: block; float: left; margin: 10px; height: 150px }
56 .divTx { display: block; float: left; margin: 10px; height: 150px }
57 .divTx label{ display: block }
57 .divTx label{ display: block }
58 .divTx textarea{ width: 135px; max-width: 135px; height: 125px; max-height: 125px; text-align: justify }
58 .divTx textarea{ width: 135px; max-width: 135px; height: 135px; max-height: 140px; text-align: justify }
59 .divTx p{ width: 135px; max-width: 135px; height: 125px; max-height: 125px; text-align: justify }
59 .divTx p{ width: 135px; max-width: 135px; height: 130px; max-height: 130px; text-align: justify }
60
60
61 .divUes { display: block; margin: 10px}
61 .divUes { display: block; margin: 10px}
62 .divUes input[type=text] { width: 240px; max-width: 240px;}
62 .divUes input[type=text] { width: 240px; max-width: 240px;}
@@ -79,3 +79,7
79 #navPatternList a{ width: 50px; border: 0px solid #1cc !important; display: block; text-align: center; line-height: 25px}
79 #navPatternList a{ width: 50px; border: 0px solid #1cc !important; display: block; text-align: center; line-height: 25px}
80 .lnkPattern{ background-color: #ccc !important; color: #eee;}
80 .lnkPattern{ background-color: #ccc !important; color: #eee;}
81 .lnkPatternSelected{ background-color: #2cc !important; color: #fff;}
81 .lnkPatternSelected{ background-color: #2cc !important; color: #fff;}
82
83 .divListofPatterns{ width: 650px; display: block; border: 1px solid #1cc !important; margin: 0 auto}
84 .divPattern{ width: 600px; display: block; border: 1px solid #f00 !important; margin: 2px auto; }
85
@@ -5,29 +5,30
5 <div id="content">
5 <div id="content">
6 <div id="divPattern">
6 <div id="divPattern">
7 <div class="divUes">
7 <div class="divUes">
8 <label for="lblFile">File:</label>
8 <label for="lblFile">File: {{ txtFilename }}</label>
9 <label for="lblFilename">{{ txtFilename }}</label>
10 </div>
9 </div>
11 <div class="divUes">
10 <div class="divUes">
12 <label for="lblExperiment">Experiment:</label>
11 <label for="lblExperiment">Experiment: {{ expName }}</label><br />
13 <p>{{ expName }}</p>
12 <label for="lblNumber">Number of patterns: {{ num_patterns }}</label>
14 <label for="lblNumber">Number of patterns:</label>
15 <p>{{ num_patterns }}</p>
16 </div>
13 </div>
17 {% if patterns %}
14 {% if patterns %}
18 <div>
15 <div class="divListofPatterns">
19 {% for element in patterns %}
16 {% for element in patterns %}
20 <div>
17 <div class="divPattern">
21 <label for="lblNumber">Pattern: {{ element.number }}</label>
18 <div>
19 <label for="lblNumber">Pattern: {{ element.number }}</label>
20 </div>
21 <div class="divAntenna">
22 <label for="lblAntennaUp">Antenna Up:</label>
23 <p>{{ element.up }}</p>
24 </div>
25 <div class="divAntenna">
26 <label for="lblAntennaDown">Antenna Down:</label>
27 <p>{{ element.down }}</p>
28 </div>
29 <div class="cleardivs"></div>
22 </div>
30 </div>
23 <div>
31 <div class="cleardivs"></div>
24 <label for="lblAntennaUp">Antenna Up:</label>
25 <p>{{ element.up }}</p>
26 </div>
27 <div>
28 <label for="lblAntennaDown">Antenna Down:</label>
29 <p>{{ element.down }}</p>
30 </div>
31 {% endfor %}
32 {% endfor %}
32 </div>
33 </div>
33 {% endif %}
34 {% endif %}
@@ -37,14 +37,34
37
37
38 def getPatterns(self, content):
38 def getPatterns(self, content):
39 lsPattern = []
39 lsPattern = []
40 index = 8
40 patterns = self.getValueofPattern(content)
41 for element in patterns:
42 if element != "":
43 strValue = element.replace("=","/")
44 pattern = strValue.split("/")
45 dicPattern = {"number" : pattern[0], "up" : pattern[1], "down" : pattern[2]}
46 lsPattern.append(dicPattern)
41
47
42 for i in range(0, self.number_patterns):
48 return lsPattern
43 first = i+index
49
44 second = first+index
50 def getValueofPattern(self, content):
45 antennaUp = content[i:first]
51 strValue = "".join(element.replace("\n","+").strip() for element in content)
46 antennaDown = content[first+1:second]
52 strValue = strValue.replace("\r","+")
47 dicPattern = {"number" : content[i], "up" : antennaUp, "down" : antennaDown}
53 strValue = strValue.replace("$","")
48 lsPattern.append(dicPattern)
54 strValue = strValue.replace("]]+++[[","]]/[[")
55 strValue = strValue.replace("]]++[[","]]/[[")
56 strValue = strValue.replace("]]+[[","]]/[[")
57 strValue = strValue.replace("],++[","],[")
58 strValue = strValue.replace("],+[","],[")
59 strValue = strValue.replace("]]+++","]]|")
60 strValue = strValue.replace("]]++","]]|")
61 strValue = strValue.replace("]]+","]]|")
62 strValue = strValue.replace(" =++[[","=[[")
63 strValue = strValue.replace("=++[[","=[[")
64 strValue = strValue.replace(" =+[[","=[[")
65 strValue = strValue.replace("=+[[","=[[")
66 strValue = strValue.replace("+","").strip()
67 #print strValue
68 lsPatterns = strValue.split("|")
49
69
50 return lsPattern No newline at end of file
70 return lsPatterns No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now