1 | import xmlrpclib |
---|
2 | import os |
---|
3 | import shutil |
---|
4 | import subprocess |
---|
5 | import socket |
---|
6 | import threading |
---|
7 | import datetime |
---|
8 | import math |
---|
9 | #from math import pi |
---|
10 | |
---|
11 | import lliurex.lliurexup as LliurexUpCore |
---|
12 | |
---|
13 | from gi.repository import Gtk, Gdk, GObject, GLib, PangoCairo, Pango |
---|
14 | |
---|
15 | import signal |
---|
16 | signal.signal(signal.SIGINT, signal.SIG_DFL) |
---|
17 | |
---|
18 | |
---|
19 | class LliurexUpConnect(): |
---|
20 | |
---|
21 | def __init__(self): |
---|
22 | |
---|
23 | self.llxUpCore=LliurexUpCore.LliurexUpCore() |
---|
24 | GObject.threads_init() |
---|
25 | |
---|
26 | #self.saveTargetMetapackagePath=os.path.join(self.llxUpCore.processPath,"targetMetapackage") |
---|
27 | self.preactions_token=os.path.join(self.llxUpCore.processPath,'preactions_token') |
---|
28 | self.upgrade_token=os.path.join(self.llxUpCore.processPath,'upgrade_token') |
---|
29 | self.installflavour_token=os.path.join(self.llxUpCore.processPath,'installflavour_token') |
---|
30 | self.postactions_token=os.path.join(self.llxUpCore.processPath,'postactions_token') |
---|
31 | #self.errorpostaction_token=os.path.join(self.llxUpCore.processPath,'errorpostaction_token') |
---|
32 | self.errorpostaction_token=self.llxUpCore.errorpostaction_token |
---|
33 | self.errorupgrade_token=self.llxUpCore.errorupgrade_token |
---|
34 | self.errorfinalmetapackage_token=self.llxUpCore.errorfinalmetapackage_token |
---|
35 | self.finalupgrade_token=self.llxUpCore.finalupgrade_token |
---|
36 | #self.errorupgrade_token=os.path.join(self.llxUpCore.processPath,'errorupgrade_token') |
---|
37 | #self.finalupgrade_token=os.path.join(self.llxUpCore.processPath,'finalupgrade_token') |
---|
38 | #self.checkInitialFlavour() |
---|
39 | |
---|
40 | |
---|
41 | #def __init__ |
---|
42 | |
---|
43 | |
---|
44 | def isLliurexUpLocked(self): |
---|
45 | |
---|
46 | code=self.llxUpCore.isLliurexUpLocked() |
---|
47 | log_msg="------------------------------------------\n"+"LLIUREX-UP-GUI STARTING AT: " + datetime.datetime.today().strftime("%d/%m/%y %H:%M:%S") +"\n------------------------------------------" |
---|
48 | |
---|
49 | if code!=0: |
---|
50 | if code ==1: |
---|
51 | log_msg="Lliurex-Up is running" |
---|
52 | elif code==2: |
---|
53 | self.log(log_msg) |
---|
54 | log_msg="Lliurex-Up is locked" |
---|
55 | |
---|
56 | self.log(log_msg) |
---|
57 | |
---|
58 | return code |
---|
59 | |
---|
60 | #def isLliurexUpLocked |
---|
61 | |
---|
62 | def isAptLocked(self): |
---|
63 | |
---|
64 | code=self.llxUpCore.isAptLocked() |
---|
65 | |
---|
66 | |
---|
67 | if code !=0: |
---|
68 | if code ==1: |
---|
69 | log_msg="Apt is running" |
---|
70 | elif code==2: |
---|
71 | log_msg="Apt is locked" |
---|
72 | |
---|
73 | self.log(log_msg) |
---|
74 | |
---|
75 | return code |
---|
76 | |
---|
77 | #def isLliurexUpLocked |
---|
78 | |
---|
79 | def isDpkgLocked(self): |
---|
80 | |
---|
81 | |
---|
82 | code=self.llxUpCore.isDpkgLocked() |
---|
83 | |
---|
84 | if code !=0: |
---|
85 | if code ==1: |
---|
86 | log_msg="Dpkg is running" |
---|
87 | elif code==2: |
---|
88 | log_msg="Dpkg is locked" |
---|
89 | elif code==3: |
---|
90 | log_msg="Apt is running" |
---|
91 | |
---|
92 | self.log(log_msg) |
---|
93 | |
---|
94 | return code |
---|
95 | |
---|
96 | #def isDpkgLocked |
---|
97 | |
---|
98 | |
---|
99 | def unlockingProcess(self): |
---|
100 | |
---|
101 | cmd=self.llxUpCore.unlockerCommand() |
---|
102 | result=subprocess.call(cmd,shell=True,stdout=subprocess.PIPE) |
---|
103 | |
---|
104 | if result!=0: |
---|
105 | log_msg="The unlocking process has failed" |
---|
106 | else: |
---|
107 | log_msg="The unlocking process finished successfully" |
---|
108 | |
---|
109 | self.log(log_msg) |
---|
110 | return result |
---|
111 | |
---|
112 | #def unlockingProcess |
---|
113 | |
---|
114 | def startLliurexUp(self): |
---|
115 | |
---|
116 | |
---|
117 | self.llxUpCore.startLliurexUp() |
---|
118 | |
---|
119 | #def startLliurexUp |
---|
120 | |
---|
121 | def free_space_check(self): |
---|
122 | |
---|
123 | if ((os.statvfs("/").f_bfree * os.statvfs("/").f_bsize) / (1024*1024*1024)) < 2: #less than 2GB available? |
---|
124 | log_msg="Not enough space on disk to upgrade (2 GB needed)" |
---|
125 | self.log(log_msg) |
---|
126 | return False |
---|
127 | |
---|
128 | else: |
---|
129 | return True |
---|
130 | |
---|
131 | #def free_space_check |
---|
132 | |
---|
133 | def checkInitialN4dStatus(self): |
---|
134 | |
---|
135 | self.statusN4d=self.llxUpCore.n4dStatus |
---|
136 | |
---|
137 | if not self.statusN4d: |
---|
138 | log_msg="N4d is not working" |
---|
139 | self.log(log_msg) |
---|
140 | |
---|
141 | return self.statusN4d |
---|
142 | |
---|
143 | #def checkInitialN4dStatus |
---|
144 | |
---|
145 | |
---|
146 | def checkInitialFlavour(self): |
---|
147 | |
---|
148 | self.targetMetapackage=self.llxUpCore.checkInitialFlavour() |
---|
149 | log_msg="Initial check metapackage. Metapackage to install: " + str(self.targetMetapackage) |
---|
150 | self.log(log_msg) |
---|
151 | self.previousFlavours=self.llxUpCore.previousFlavours |
---|
152 | log_msg="Get initial metapackage: " + str(self.previousFlavours) |
---|
153 | self.log(log_msg) |
---|
154 | return self.targetMetapackage |
---|
155 | |
---|
156 | #def checkFlavoour |
---|
157 | |
---|
158 | |
---|
159 | def canConnectToLliurexNet(self): |
---|
160 | |
---|
161 | can_connect=self.llxUpCore.canConnectToLliurexNet() |
---|
162 | |
---|
163 | if can_connect: |
---|
164 | log_msg="Can connect to lliurex.net: True" |
---|
165 | self.log(log_msg) |
---|
166 | return True |
---|
167 | |
---|
168 | else: |
---|
169 | log_msg="Can connect to lliurex.net: False" |
---|
170 | self.log(log_msg) |
---|
171 | if "lliurex-meta-server" == self.targetMetapackage or "server" in self.llxUpCore.previousFlavours: |
---|
172 | return False |
---|
173 | else: |
---|
174 | return True |
---|
175 | |
---|
176 | #def canConnectToLliurexNet |
---|
177 | |
---|
178 | |
---|
179 | def initActionsScript(self): |
---|
180 | |
---|
181 | #self.checkInitialFlavour() |
---|
182 | arg="initActions" |
---|
183 | command="DEBIAN_FRONTEND=gnome DEBIAN_PRIORITY=high " + self.llxUpCore.initActionsScript(arg) |
---|
184 | |
---|
185 | try: |
---|
186 | os.system(command) |
---|
187 | log_msg="Exec Init-Actions" |
---|
188 | self.log(log_msg) |
---|
189 | return True |
---|
190 | |
---|
191 | except Exception as e: |
---|
192 | log_msg="Exec Init-Actions.Error: " +str(e) |
---|
193 | self.log(log_msg) |
---|
194 | return False |
---|
195 | |
---|
196 | #def initActionsScript |
---|
197 | |
---|
198 | def clientCheckingMirrorIsRunning(self): |
---|
199 | |
---|
200 | is_mirror_running_inserver=self.llxUpCore.clientCheckingMirrorIsRunning() |
---|
201 | |
---|
202 | if is_mirror_running_inserver['ismirrorrunning'] ==None: |
---|
203 | log_msg="Checking if mirror in server is being updated. Error: " + str(is_mirror_running_inserver['exception']) |
---|
204 | self.log(log_msg) |
---|
205 | |
---|
206 | else: |
---|
207 | if is_mirror_running_inserver['ismirrorrunning']==True: |
---|
208 | log_msg="Mirror is being udpated in server. Unable to update the system" |
---|
209 | self.log(log_msg) |
---|
210 | |
---|
211 | |
---|
212 | return is_mirror_running_inserver['ismirrorrunning'] |
---|
213 | |
---|
214 | #def clientCheckingMirrorIsRunning |
---|
215 | |
---|
216 | def isLliurexUpIsUpdated(self): |
---|
217 | |
---|
218 | try: |
---|
219 | is_lliurexup_updated=self.llxUpCore.isLliurexUpIsUpdated() |
---|
220 | log_msg="Checking lliurex-up. Is lliurex-up updated: "+ str(is_lliurexup_updated) |
---|
221 | self.log(log_msg) |
---|
222 | return is_lliurexup_updated |
---|
223 | |
---|
224 | except Exception as e: |
---|
225 | log_msg="Checking lliurex-up. Error: " + str(e) |
---|
226 | self.log(log_msg) |
---|
227 | return True |
---|
228 | |
---|
229 | #def isLliurexUpIsUpdated |
---|
230 | |
---|
231 | def installLliurexUp(self): |
---|
232 | |
---|
233 | try: |
---|
234 | is_lliurexup_installed=self.llxUpCore.installLliurexUp() |
---|
235 | returncode=is_lliurexup_installed['returncode'] |
---|
236 | error=is_lliurexup_installed['stderrs'] |
---|
237 | log_msg="Installing lliurex-up. Returncode: " + str(returncode) + ". Error: " + str(error) |
---|
238 | self.log(log_msg) |
---|
239 | return returncode |
---|
240 | |
---|
241 | except Exception as e: |
---|
242 | log_msg="Installing lliurex-up. Error: " + str(e) |
---|
243 | self.log(log_msg) |
---|
244 | return True |
---|
245 | |
---|
246 | #def installLliurexUp |
---|
247 | |
---|
248 | |
---|
249 | def lliurexMirrorIsUpdated(self): |
---|
250 | |
---|
251 | try: |
---|
252 | is_mirror_updated=self.llxUpCore.lliurexMirrorIsUpdated() |
---|
253 | |
---|
254 | if is_mirror_updated !=None: |
---|
255 | |
---|
256 | if is_mirror_updated['action']=='update': |
---|
257 | log_msg="Checking mirror. Is mirror update: False" |
---|
258 | self.log(log_msg) |
---|
259 | return False |
---|
260 | else: |
---|
261 | log_msg="Checking mirror. Is mirror update: " + is_mirror_updated['action'] |
---|
262 | self.log(log_msg) |
---|
263 | return True |
---|
264 | else: |
---|
265 | log_msg="Checking mirror. Is mirror update: None" |
---|
266 | self.log(log_msg) |
---|
267 | return True |
---|
268 | |
---|
269 | |
---|
270 | except Exception as e: |
---|
271 | log_msg="Checking mirror. Error: " + str(e) |
---|
272 | self.log(log_msg) |
---|
273 | return True |
---|
274 | |
---|
275 | #def lliurexMirrorIsUpdated |
---|
276 | |
---|
277 | def lliurexMirrorIsRunning(self): |
---|
278 | |
---|
279 | try: |
---|
280 | is_lliurexmirror_running=self.llxUpCore.lliurexMirrorIsRunning() |
---|
281 | return is_lliurexmirror_running |
---|
282 | |
---|
283 | except Exception as e: |
---|
284 | log_msg="Updating mirror. Error: " + str(e) |
---|
285 | self.log(log_msg) |
---|
286 | return False |
---|
287 | |
---|
288 | #def lliurexMirrorIsRunning |
---|
289 | |
---|
290 | def getPercentageLliurexMirror(self): |
---|
291 | |
---|
292 | try: |
---|
293 | percentage_mirror=self.llxUpCore.getPercentageLliurexMirror() |
---|
294 | if percentage_mirror != None: |
---|
295 | return percentage_mirror |
---|
296 | else: |
---|
297 | return 0 |
---|
298 | |
---|
299 | except Exception as e: |
---|
300 | return 0 |
---|
301 | |
---|
302 | |
---|
303 | #def getPercentageLliurexMirror |
---|
304 | |
---|
305 | def getLliurexVersionLocal(self): |
---|
306 | |
---|
307 | try: |
---|
308 | |
---|
309 | self.lliurexVersionLocal=self.llxUpCore.getLliurexVersionLocal() |
---|
310 | log_msg="Get LliurexVersion installed: " + str(self.lliurexVersionLocal["installed"]) |
---|
311 | self.log(log_msg) |
---|
312 | log_msg="Get LliurexVersion candidate from Local repository: " + str(self.lliurexVersionLocal["candidate"]) |
---|
313 | self.log(log_msg) |
---|
314 | #self.lliurexVersionLocal=self.lliurexVersionLocal["candidate"] |
---|
315 | |
---|
316 | except Exception as e: |
---|
317 | log_msg="Get LliurexVersion from Local repository. Error: " + str(e) |
---|
318 | self.log(log_msg) |
---|
319 | self.lliurexVersionLocal={"installed":None,"candidate":None} |
---|
320 | |
---|
321 | return self.lliurexVersionLocal |
---|
322 | |
---|
323 | #def getLliurexVersionLocal( |
---|
324 | |
---|
325 | def getLliurexVersionNet(self): |
---|
326 | |
---|
327 | try: |
---|
328 | self.lliurexVersionNet=self.llxUpCore.getLliurexVersionLliurexNet()["candidate"] |
---|
329 | log_msg="Get LliurexVersion candidate from Lliurex Net: " + str(self.lliurexVersionNet) |
---|
330 | self.log(log_msg) |
---|
331 | |
---|
332 | |
---|
333 | except Exception as e: |
---|
334 | log_msg="Get LliurexVersion from Lliurex Net. Error: " + str(e) |
---|
335 | self.log(log_msg) |
---|
336 | self.lliurexVersionNet=None |
---|
337 | |
---|
338 | return self.lliurexVersionNet |
---|
339 | |
---|
340 | #def getLliurexVersionNet |
---|
341 | |
---|
342 | def installInitialFlavour(self,flavourToInstall): |
---|
343 | |
---|
344 | try: |
---|
345 | is_flavour_installed=self.llxUpCore.installInitialFlavour(flavourToInstall) |
---|
346 | returncode=is_flavour_installed['returncode'] |
---|
347 | error=is_flavour_installed['stderrs'] |
---|
348 | log_msg="Install initial metapackage:" + flavourToInstall + ": Returncode: " + str(returncode) + " Error: " + str(error) |
---|
349 | self.log(log_msg) |
---|
350 | return returncode |
---|
351 | |
---|
352 | except Exception as e: |
---|
353 | print str(e) |
---|
354 | log_msg="Install initial metapackage: " + flavourToInstall + ". Error: " + str(e) |
---|
355 | self.log(log_msg) |
---|
356 | return 1 |
---|
357 | |
---|
358 | #def installInitialFlavour |
---|
359 | |
---|
360 | def getPackagesToUpdate(self): |
---|
361 | |
---|
362 | #ref_flavour=["lliurex-meta-server","lliurex-meta-client", "lliurex-meta-desktop", "lliurex-meta-music", "lliurex-meta-pyme", "lliurex-meta-infantil"] |
---|
363 | packages_parse=[] |
---|
364 | self.total_size=0 |
---|
365 | #self.incorrect_flavours=[] |
---|
366 | |
---|
367 | try: |
---|
368 | packages=self.llxUpCore.getPackagesToUpdate() |
---|
369 | if len(packages)>0: |
---|
370 | for item in packages: |
---|
371 | version=packages[item]['candidate'] |
---|
372 | size=self.getSizePackagesToUpdate(item) |
---|
373 | install=str(packages[item]['install']) |
---|
374 | packages_parse.append(item+";"+version+";"+size+";"+install) |
---|
375 | |
---|
376 | log_msg="Get packages to update. Number of packages: " + str(len(packages)) |
---|
377 | self.log(log_msg) |
---|
378 | |
---|
379 | except Exception as e: |
---|
380 | log_msg="Get packages to update. Error: " + str(e) |
---|
381 | self.log(log_msg) |
---|
382 | |
---|
383 | self.total_size=self.convert_size(self.total_size) |
---|
384 | return packages_parse,self.total_size |
---|
385 | |
---|
386 | #def getPackagesToUpdate |
---|
387 | |
---|
388 | def getSizePackagesToUpdate(self,pkg): |
---|
389 | size=0 |
---|
390 | try: |
---|
391 | command='apt-cache show ' + pkg + ' |grep "^Size:" |cut -d " " -f2 |head -1' |
---|
392 | p=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE) |
---|
393 | size=p.stdout.readline().strip() |
---|
394 | self.total_size=(self.total_size)+int(size) |
---|
395 | size=self.convert_size(size) |
---|
396 | return size |
---|
397 | |
---|
398 | except Exception as e: |
---|
399 | print e |
---|
400 | return self.convert_size(size) |
---|
401 | |
---|
402 | |
---|
403 | def convert_size(self,size_bytes): |
---|
404 | |
---|
405 | size_bytes=float(size_bytes) |
---|
406 | if (size_bytes == 0): |
---|
407 | return '0B' |
---|
408 | |
---|
409 | size_name = ("B", "KB", "MB", "GB") |
---|
410 | i = int(math.floor(math.log(size_bytes, 1024))) |
---|
411 | p = math.pow(1024, i) |
---|
412 | s = round(size_bytes/p,) |
---|
413 | s=int(s) |
---|
414 | return '%s %s' % (s, size_name[i]) |
---|
415 | |
---|
416 | |
---|
417 | def checkIncorrectFlavours(self): |
---|
418 | |
---|
419 | incorrectFlavours=self.llxUpCore.checkIncorrectFlavours() |
---|
420 | |
---|
421 | if incorrectFlavours: |
---|
422 | log_msg="Checking incorrect metapackages. Others metapackages detected: " + str(incorrectFlavours) |
---|
423 | self.log(log_msg) |
---|
424 | else: |
---|
425 | log_msg="Checking incorrect metapackages. Others metapackages not detected" |
---|
426 | self.log(log_msg) |
---|
427 | |
---|
428 | return incorrectFlavours |
---|
429 | |
---|
430 | #def checkIncorrectFlavours |
---|
431 | |
---|
432 | def getPackageChangelog(self,package): |
---|
433 | |
---|
434 | changelog_file=os.path.join(self.llxUpCore.changelogsPath,package) |
---|
435 | changelog="Changelog not found" |
---|
436 | |
---|
437 | if not os.path.exists(changelog_file): |
---|
438 | #os.system('LANG=C LANGUAGE=en apt-get changelog %s > %s'%(package,changelog_file)) |
---|
439 | cmd='LANG=C LANGUAGE=en apt-get changelog %s > %s'%(package,changelog_file) |
---|
440 | p=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE) |
---|
441 | poutput,perror=p.communicate() |
---|
442 | |
---|
443 | if len(perror)>0: |
---|
444 | return changelog |
---|
445 | |
---|
446 | try: |
---|
447 | cmd="sed -i '/Get:1 http\|Fetched/d' " + str(changelog_file) |
---|
448 | os.system(cmd) |
---|
449 | f=open(changelog_file,"r") |
---|
450 | changelog=f.readlines() |
---|
451 | f.close() |
---|
452 | |
---|
453 | except Exception as e: |
---|
454 | changelog="Changelog not found" |
---|
455 | |
---|
456 | return changelog |
---|
457 | |
---|
458 | #def getPackageChangelog |
---|
459 | |
---|
460 | def preActionsScript(self): |
---|
461 | |
---|
462 | self.preActions=self.llxUpCore.preActionsScript() |
---|
463 | self.preActions='DEBIAN_FRONTEND=gnome DEBIAN_PRIORITY=high ' +self.preActions + ' ;touch ' + self.preactions_token + '\n' |
---|
464 | log_msg="Exec Pre-Actions" |
---|
465 | self.log(log_msg) |
---|
466 | return self.preActions |
---|
467 | |
---|
468 | #def preActionsScript |
---|
469 | |
---|
470 | def distUpgradeProcess(self): |
---|
471 | |
---|
472 | self.distupgrade=self.llxUpCore.distUpgradeProcess() |
---|
473 | self.distupgrade='DEBIAN_FRONTEND=gnome DEBIAN_PRIORITY=high ' +self.distupgrade + ' ;touch ' + self.upgrade_token + '\n' |
---|
474 | log_msg="Exec Dist-uggrade" |
---|
475 | self.log(log_msg) |
---|
476 | return self.distupgrade |
---|
477 | |
---|
478 | #def distUpgradeProcess |
---|
479 | |
---|
480 | def checkErrorDistUpgrade(self): |
---|
481 | |
---|
482 | error=False |
---|
483 | try: |
---|
484 | errorDistUpgrade=self.llxUpCore.checkErrorDistUpgrade() |
---|
485 | if errorDistUpgrade or self.errorCheckFlavour: |
---|
486 | error=True |
---|
487 | log_msg="Dist-upgrade process ending with errors" |
---|
488 | self.log(log_msg) |
---|
489 | else: |
---|
490 | log_msg="Dist-upgrade process ending OK" |
---|
491 | self.log(log_msg) |
---|
492 | |
---|
493 | except Exception as e: |
---|
494 | print e |
---|
495 | log_msg="Error checking distupgrade. Error: " + str(e) |
---|
496 | self.log(log_msg) |
---|
497 | error=True |
---|
498 | |
---|
499 | return error |
---|
500 | |
---|
501 | |
---|
502 | #def checkErrorDistUpgrade |
---|
503 | |
---|
504 | def getStatusPackage(self): |
---|
505 | |
---|
506 | command='dpkg -l |grep "^i[i]"' |
---|
507 | packages_status=[] |
---|
508 | try: |
---|
509 | p = subprocess.Popen(command,shell=True,stdout=subprocess.PIPE) |
---|
510 | for line in iter(p.stdout.readline,""): |
---|
511 | tmp=str(line.strip().split()[1].split(":")[0])+"_"+str(line.strip().split()[2]) |
---|
512 | packages_status.append(tmp) |
---|
513 | |
---|
514 | except Exception as e: |
---|
515 | print str(e) |
---|
516 | |
---|
517 | return packages_status |
---|
518 | |
---|
519 | def checkFinalFlavour(self): |
---|
520 | |
---|
521 | self.errorCheckFlavour=False |
---|
522 | flavourToInstall=None |
---|
523 | |
---|
524 | self.checkFinalN4dStatus() |
---|
525 | |
---|
526 | try: |
---|
527 | #flavourToInstall=self.llxUpCore.checkFinalFlavour() |
---|
528 | flavourToInstall=self.llxUpCore.checkFlavour() |
---|
529 | log_msg="Final check metapackage. Metapackage to install: " + str(flavourToInstall) |
---|
530 | self.log(log_msg) |
---|
531 | |
---|
532 | except Exception as e: |
---|
533 | self.errorCheckFlavour=True |
---|
534 | log_msg="Final check metapackage. Error: " + str(e) |
---|
535 | self.log(log_msg) |
---|
536 | |
---|
537 | |
---|
538 | return flavourToInstall |
---|
539 | |
---|
540 | |
---|
541 | #def checkFinalFlavour |
---|
542 | |
---|
543 | def installFinalFlavour(self,flavourToInstall): |
---|
544 | |
---|
545 | self.command=self.llxUpCore.installFinalFlavour(flavourToInstall) |
---|
546 | self.command='DEBIAN_FRONTEND=gnome DEBIAN_PRIORITY=high ' +self.command + ' 2> >(tee ' + self.errorfinalmetapackage_token + ');touch ' + self.installflavour_token + ' ; exit'+' \n' |
---|
547 | log_msg="Install final metapackage" |
---|
548 | self.log(log_msg) |
---|
549 | return self.command |
---|
550 | |
---|
551 | #def installFinalFlavour |
---|
552 | |
---|
553 | def postActionsScript(self): |
---|
554 | |
---|
555 | self.postActions=self.llxUpCore.postActionsScript() |
---|
556 | self.postActions='DEBIAN_FRONTEND=gnome DEBIAN_PRIORITY=high '+self.postActions + ' 2> >(tee ' + self.errorpostaction_token + ') ;touch ' + self.postactions_token + ' \n' |
---|
557 | #self.postActions=self.postActions + ' ;touch ' + self.postactions_token + ' \n' |
---|
558 | |
---|
559 | log_msg="Exec Post-Actions" |
---|
560 | self.log(log_msg) |
---|
561 | return self.postActions |
---|
562 | |
---|
563 | #def postActionsScript |
---|
564 | |
---|
565 | def checkFinalN4dStatus(self): |
---|
566 | |
---|
567 | self.llxUpCore.checkN4dStatus() |
---|
568 | |
---|
569 | if not self.llxUpCore.n4dStatus: |
---|
570 | log_msg="N4d is not working" |
---|
571 | |
---|
572 | self.log(log_msg) |
---|
573 | |
---|
574 | #def checkFinalN4dStatus |
---|
575 | |
---|
576 | |
---|
577 | def cleanEnvironment(self): |
---|
578 | |
---|
579 | try: |
---|
580 | self.llxUpCore.cleanEnvironment() |
---|
581 | log_msg="Clean environment: OK" |
---|
582 | self.log(log_msg) |
---|
583 | |
---|
584 | except Exception as e: |
---|
585 | log_msg="Clean environment. Error :" + str(e) |
---|
586 | self.log(log_msg) |
---|
587 | |
---|
588 | #def cleanEnvironment |
---|
589 | |
---|
590 | def cleanLliurexUpLock(self): |
---|
591 | |
---|
592 | try: |
---|
593 | self.llxUpCore.cleanLliurexUpLock() |
---|
594 | |
---|
595 | except Exception as e: |
---|
596 | print e |
---|
597 | |
---|
598 | #def cleanLliurexUpLock |
---|
599 | |
---|
600 | |
---|
601 | def log(self,msg): |
---|
602 | |
---|
603 | log_file="/var/log/lliurex-up.log" |
---|
604 | f=open(log_file,"a+") |
---|
605 | f.write(msg + '\n') |
---|
606 | f.close() |
---|
607 | |
---|
608 | #def log |
---|