|
0 |
-- univention-updater/modules/univention/management/console/handlers/update/__init__.py |
0 |
++ univention-updater/modules/univention/management/console/handlers/update/__init__.py |
Lines 41-46
import univention.debug as ud
|
Link Here
|
---|
|
41 |
import univention.config_registry |
41 |
import univention.config_registry |
42 |
|
42 |
|
43 |
from univention.updater import UniventionUpdater |
43 |
from univention.updater import UniventionUpdater |
|
|
44 |
from json import JsonReader, JsonWriter |
44 |
|
45 |
|
45 |
import os |
46 |
import os |
46 |
import subprocess, string, time |
47 |
import subprocess, string, time |
Lines 125-131
command_description = {
|
Link Here
|
---|
|
125 |
values = { |
126 |
values = { |
126 |
}, |
127 |
}, |
127 |
), |
128 |
), |
128 |
|
129 |
'update/tail_file': umch.command( |
|
|
130 |
short_description = _('Get tail of logfile' ), |
131 |
method = 'tail_file', |
132 |
values = { |
133 |
'filename': umc.String( _( 'Name of the log file' ), required = False ), |
134 |
}, |
135 |
), |
129 |
} |
136 |
} |
130 |
|
137 |
|
131 |
|
138 |
|
Lines 146-151
class handler(umch.simpleHandler):
|
Link Here
|
---|
|
146 |
|
153 |
|
147 |
self.ucr_reinit = False |
154 |
self.ucr_reinit = False |
148 |
|
155 |
|
|
|
156 |
self.tail_fn2fd = {} |
149 |
|
157 |
|
150 |
def overview(self, object): |
158 |
def overview(self, object): |
151 |
_d = ud.function('update.handler.overview') |
159 |
_d = ud.function('update.handler.overview') |
Lines 389-394
class handler(umch.simpleHandler):
|
Link Here
|
---|
|
389 |
self.finished(object.id(), stdout) |
397 |
self.finished(object.id(), stdout) |
390 |
|
398 |
|
391 |
|
399 |
|
|
|
400 |
def tail_file(self, object): |
401 |
_d = ud.function('update.handler.tail_file') |
402 |
|
403 |
logfn = object.options.get('filename') |
404 |
if not logfn in ('/var/log/univention/updater.log'): |
405 |
self.finished(object.id(), '%s: access not allowed by UMC module' % logfn) |
406 |
return |
407 |
|
408 |
# create fd if fd is not present |
409 |
if not logfn in self.tail_fn2fd: |
410 |
fd = open(logfn,'r+') |
411 |
self.tail_fn2fd[logfn] = fd |
412 |
else: |
413 |
fd = self.tail_fn2fd[logfn] |
414 |
|
415 |
curpos = fd.tell() |
416 |
fd.seek(0,2) # seek to file end |
417 |
endpos = fd.tell() |
418 |
fd.seek(curpos,0) # seek back to cur pos |
419 |
pendingbytes = endpos - curpos |
420 |
data = fd.read(pendingbytes) # get pending data |
421 |
ud.debug(ud.ADMIN, ud.PROCESS, 'update.handler.tail_file: %d %d %d %d' % (curpos, endpos, pendingbytes, len(data))) |
422 |
|
423 |
self.finished(object.id(), {'data': data, 'test': 'das ist ein test'}) |
424 |
|
425 |
def _web_tail_file(self, object, res): |
426 |
_d = ud.function('update.handler._web_tail_file') |
427 |
content_type = 'application/json' |
428 |
content = '' |
429 |
|
430 |
data = {} |
431 |
data['identifier'] = 'data' |
432 |
data['label'] = 'updater data' |
433 |
data['items'] = [ res.dialog ] |
434 |
try: |
435 |
json = JsonWriter() |
436 |
content = json.write(data) |
437 |
except: |
438 |
ud.debug(ud.ADMIN, ud.PROCESS, 'update.handler._web_tail_file: failed to create JSON: %s' % (traceback.format_exc().replace('%','#')) ) |
439 |
res.dialog = { 'Content-Type': content_type, 'Content': content } |
440 |
self.revamped( object.id(), res, rawresult = True ) |
441 |
|
442 |
|
392 |
####################### |
443 |
####################### |
393 |
# The revamp functions |
444 |
# The revamp functions |
394 |
####################### |
445 |
####################### |
Lines 506-512
class handler(umch.simpleHandler):
|
Link Here
|
---|
|
506 |
frame_release = umcd.Frame([list_release], _('Release information')) |
557 |
frame_release = umcd.Frame([list_release], _('Release information')) |
507 |
frame_component = umcd.Frame([list_component], _('Components')) |
558 |
frame_component = umcd.Frame([list_component], _('Components')) |
508 |
|
559 |
|
509 |
res.dialog = [frame_release, frame_component] |
560 |
javascript = umcd.HTML ("""<script type='text/javascript'> |
|
|
561 |
var umc = {}; |
562 |
umc.updater = {}; |
563 |
umc.updater.updateData = function(sessionid) { |
564 |
var foocallback = function (item, request) { |
565 |
dojo.byId ('taildata').innerHTML = dojo.byId ('taildata').innerHTML + item.data; |
566 |
dojo.byId('tailwnd').scrollTop = dojo.byId('tailwnd').scrollHeight; |
567 |
return false; |
568 |
}; |
569 |
|
570 |
if (umc.updater.store) { |
571 |
umc.updater.store.close () |
572 |
} |
573 |
umc.updater.store = new dojo.data.ItemFileReadStore ({url:'ajax.py?session_id='+sessionid+'&umcpcmd=update/tail_file&filename=/var/log/univention/updater.log&date=' + new Date ().getTime ()}); |
574 |
umc.updater.store.fetch ( |
575 |
{ |
576 |
query: {data: '*'}, |
577 |
onItem: foocallback, |
578 |
} |
579 |
); |
580 |
}; |
581 |
dojo.addOnLoad (function () { |
582 |
window.setInterval( function () {umc.updater.updateData ('%s');}, 2000); |
583 |
}); |
584 |
dojo.require ('dojo.data.ItemFileReadStore'); |
585 |
</script>""" % (self._sessionid)) |
586 |
divitems = umcd.HTML('<div id="tailwnd" style="width:800px; height:200px; overflow: scroll; border:1px solid #000000; margin: 1px"><pre id="taildata">TEST</pre></div>') |
587 |
|
588 |
list_test = umcd.List() |
589 |
list_test.add_row([divitems, javascript]) |
590 |
frame_test = umcd.Frame([list_test], _('LOG TEST')) |
591 |
|
592 |
res.dialog = [frame_test, frame_release, frame_component] |
510 |
if frame_info: |
593 |
if frame_info: |
511 |
res.dialog.insert( 0, frame_info ) |
594 |
res.dialog.insert( 0, frame_info ) |
512 |
|
595 |
|