From ee9f3a54c5fe17cf481051d9c951a242200ead02 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Wed, 22 Aug 2012 09:53:41 -0500 Subject: LinHES-system: cleanup of the osd system. rename xmsg.py to msg_osd.py change diskspace.sh to use msg_client.py --- abs/core/LinHES-system/PKGBUILD | 8 +- abs/core/LinHES-system/diskspace.sh | 4 +- abs/core/LinHES-system/lh_message.sh | 27 ++---- abs/core/LinHES-system/msg_osd.py | 163 +++++++++++++++++++++++++++++++++++ abs/core/LinHES-system/xmsg.py | 163 ----------------------------------- 5 files changed, 175 insertions(+), 190 deletions(-) create mode 100644 abs/core/LinHES-system/msg_osd.py delete mode 100644 abs/core/LinHES-system/xmsg.py diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index d807f78..2cfe372 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-system pkgver=2 -pkgrel=54 +pkgrel=55 arch=('i686' 'x86_64') MVDIR=$startdir/pkg/usr/LH BINDIR=$startdir/pkg/usr/bin @@ -14,7 +14,7 @@ binfiles="LinHES-start optimize_mythdb.py unclutter-toggle.sh tvterm.sh mythfrontend-start set_windowmanager.sh myth_status.py myth_status.sh - xmsg.py install_supplemental_service.sh + msg_osd.py install_supplemental_service.sh lh_system_backup_job lh_system_restore_job lh_system_host_update @@ -26,7 +26,7 @@ binfiles="LinHES-start optimize_mythdb.py msg_client.py msg_daemon.py gen_is_xml.py" source=(LinHES-session LinHES-profile.sh $binfiles alsa-base myth_mtc.lr - diskspace smolt.cron cacheclean.cron readme_is_xml) + diskspace cacheclean.cron readme_is_xml) build() { cd $startdir/src @@ -50,7 +50,7 @@ build() { install -m644 -D $startdir/src/alsa-base $startdir/pkg/etc/modprobe.d/alsa-base.conf install -m644 -D $startdir/src/readme_is_xml $startdir/pkg/etc/gen_is_xml.d/readme_is_xml - install -m755 -D $startdir/src/smolt.cron $startdir/pkg/etc/cron.weekly/smolt.cron + # install -m755 -D $startdir/src/smolt.cron $startdir/pkg/etc/cron.weekly/smolt.cron install -m755 -D $startdir/src/cacheclean.cron $startdir/pkg/etc/cron.weekly/cacheclean.cron install -m755 -D $startdir/src/diskspace $startdir/pkg/etc/cron.tenminutes/diskspace mkdir $startdir/pkg/etc/logrotate.d diff --git a/abs/core/LinHES-system/diskspace.sh b/abs/core/LinHES-system/diskspace.sh index 34e00cf..dd8596c 100755 --- a/abs/core/LinHES-system/diskspace.sh +++ b/abs/core/LinHES-system/diskspace.sh @@ -17,6 +17,7 @@ CUT='/usr/bin/cut' HOSTNAME='/usr/bin/hostname' DATE='/bin/date' OSD_CAT='/usr/bin/osd_cat' +MSG_CLIENT='/usr/LH/bin/msg_client.py" export DISPLAY=:0.0 # # Static System Variables @@ -72,7 +73,8 @@ $DF -HPl | $GREP -E "^/dev/" | $AWK '{ print $5 " " $6 " " $1 }' | while read OU else echo "WARNING: ${PARTITION} (${DEVICE}) is ${USED_PCENT}% full on ${THIS_HOST}." #| if [ $OSD = true ] && [ ${PARTITION} = / ]; then - echo "WARNING: The root (${PARTITION}) partition is ${USED_PCENT}% full on ${THIS_HOST}." | $OSD_CAT --pos=top --offset=40 --align=center --delay=10 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font & + #echo "WARNING: The root (${PARTITION}) partition is ${USED_PCENT}% full on ${THIS_HOST}." | $OSD_CAT --pos=top --offset=40 --align=center --delay=10 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font & + $MSG_CLIENT "WARNING: The root (${PARTITION}) partition is ${USED_PCENT}% full on ${THIS_HOST}." fi fi fi diff --git a/abs/core/LinHES-system/lh_message.sh b/abs/core/LinHES-system/lh_message.sh index deddcff..f186bf3 100644 --- a/abs/core/LinHES-system/lh_message.sh +++ b/abs/core/LinHES-system/lh_message.sh @@ -1,4 +1,8 @@ #!/bin/bash +# This script is called by msd_daemon.py and used to display messages on the osd_cat +# May be called directly but best used through msg_daemon + + MYTH_RUN_STATUS="1" . /etc/profile . /etc/systemconfig @@ -19,33 +23,12 @@ fi font="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*" } - -# function delay_osd(){ -# if [ x$STARTUP_STYLE = xmythvantage ] -# then -# cmd="ps -ef | grep -v grep | grep -q xmsg.py" -# else -# cmd="ps -ef | grep -v grep | grep -q osd_cat" -# fi -# -# eval $cmd -# -# rc=$? -# while [ $rc = 0 ] -# do -# eval $cmd -# rc=$? -# done -# -# -# } - function msg_osd(){ DISPLAY=127.0.0.1:0 echo -e "$1" | DISPLAY=127.0.0.1:0 osd_cat --pos=middle --align=center --offset=200 --delay=5 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font } function msg_pyosd(){ - DISPLAY=127.0.0.1:0 /usr/LH/bin/xmsg.py -m "$1" + DISPLAY=127.0.0.1:0 /usr/LH/bin/msg_osd.py -m "$1" } function msg(){ diff --git a/abs/core/LinHES-system/msg_osd.py b/abs/core/LinHES-system/msg_osd.py new file mode 100644 index 0000000..669a796 --- /dev/null +++ b/abs/core/LinHES-system/msg_osd.py @@ -0,0 +1,163 @@ +#!/usr/bin/python2 +# other modules + +import sys, string +import aosd +import ConfigParser +import getopt + + +# ================================= + + +class msg(): + def scroll(self,osd, width, height, display_time,position): + pos = position + step = 1 + + osd.set_position(pos, width, height) + (x, y, _, _) = osd.get_geometry() + osd.set_position_offset(width, height) + osd.show() + + x -= 1 + y += height - 1; + for i in range(1, height + 1, step): + osd.loop_for(5) + y -= step + osd.set_geometry(x, y, width, i) + + osd.set_position(pos, width, height) + osd.set_position_offset(-1, -1) + (x, y, _, _) = osd.get_geometry() + #time to display + osd.loop_for(display_time) + + for i in range(height, 0, -step): + y += step + osd.set_geometry(x, y, width, i); + osd.loop_for(1); + + osd.hide(); + + def setup(self,font_color,font_type): + osd = aosd.AosdText() + osd.set_transparency(aosd.TRANSPARENCY_COMPOSITE) + if osd.get_transparency() != aosd.TRANSPARENCY_COMPOSITE: + osd.set_transparency(aosd.TRANSPARENCY_NONE) + + osd.geom_x_offset = 10 + osd.geom_y_offset = 0 + + osd.back_color = "white" + osd.back_opacity = 50 + + osd.shadow_color = "black" + osd.shadow_opacity = 127 + osd.shadow_x_offset = 2 + osd.shadow_y_offset = 2 + + osd.fore_color = font_color + osd.fore_opacity = 255 + + osd.set_font(font_type) + osd.wrap = aosd.PANGO_WRAP_WORD_CHAR + osd.alignment = aosd.PANGO_ALIGN_LEFT + osd.set_layout_width(osd.get_screen_wrap_width()) + return osd + + def set_string(self, osd, text): + osd.set_text(text) + return osd.get_text_size() + + def setup_config(self): + module_config = ConfigParser.RawConfigParser() + try: + module_config.read('/usr/MythVantage/etc/msg.cfg') + except: + pass + return module_config + + + + def display (self,flags): + """ + parse the msg for display. + """ + try: + text,config_section=flags.split("|") + if config_section == '': + config_section="default" + except: + text=flags + config_section="default" + + module_config = self.setup_config() + + display_time=5000 + position=6 + font_color="green" + font_type="Times New Roman Italic 36" + try: + display_time = int(module_config.get(config_section,"display_time")) + except: + pass + try: + position = int(module_config.get(config_section,"position")) + except: + pass + try: + font_color = module_config.get(config_section,"font_color") + except: + pass + try: + font_type = module_config.get(config_section,"font_type") + except: + pass + + #this bit of code converts a \n to EOL/BREAK + textline=text.split('\\n') + try: + textline.remove(' ') + except: + pass + text=chr(10).join(textline) + + #cmd = sub_process.Popen("/usr/bin/wall %s" % text,stdout=sub_process.PIPE,shell=True) + #data = cmd.communicate()[0] + osd = self.setup(font_color, font_type) + width, height = self.set_string(osd, text) + self.scroll(osd, width, height, display_time, position) + + return ("Message delivered") + + + + +def main(): + try: + opts, args = getopt.getopt(sys.argv[1:], "hm:", ["help", "msg="]) + except getopt.GetoptError, err: + # print help information and exit: + print str(err) # will print something like "option -a not recognized" + usage() + sys.exit(2) + in_msg = None + + for o, a in opts: + if o in ("-h", "--help"): + usage() + sys.exit() + elif o in ("-m", "--msg"): + in_msg = a + else: + assert False, "unhandled option" + txt_msg=in_msg + out_msg=msg() + + out_msg.display(txt_msg) + +if __name__ == "__main__": + main() + + diff --git a/abs/core/LinHES-system/xmsg.py b/abs/core/LinHES-system/xmsg.py deleted file mode 100644 index 669a796..0000000 --- a/abs/core/LinHES-system/xmsg.py +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/python2 -# other modules - -import sys, string -import aosd -import ConfigParser -import getopt - - -# ================================= - - -class msg(): - def scroll(self,osd, width, height, display_time,position): - pos = position - step = 1 - - osd.set_position(pos, width, height) - (x, y, _, _) = osd.get_geometry() - osd.set_position_offset(width, height) - osd.show() - - x -= 1 - y += height - 1; - for i in range(1, height + 1, step): - osd.loop_for(5) - y -= step - osd.set_geometry(x, y, width, i) - - osd.set_position(pos, width, height) - osd.set_position_offset(-1, -1) - (x, y, _, _) = osd.get_geometry() - #time to display - osd.loop_for(display_time) - - for i in range(height, 0, -step): - y += step - osd.set_geometry(x, y, width, i); - osd.loop_for(1); - - osd.hide(); - - def setup(self,font_color,font_type): - osd = aosd.AosdText() - osd.set_transparency(aosd.TRANSPARENCY_COMPOSITE) - if osd.get_transparency() != aosd.TRANSPARENCY_COMPOSITE: - osd.set_transparency(aosd.TRANSPARENCY_NONE) - - osd.geom_x_offset = 10 - osd.geom_y_offset = 0 - - osd.back_color = "white" - osd.back_opacity = 50 - - osd.shadow_color = "black" - osd.shadow_opacity = 127 - osd.shadow_x_offset = 2 - osd.shadow_y_offset = 2 - - osd.fore_color = font_color - osd.fore_opacity = 255 - - osd.set_font(font_type) - osd.wrap = aosd.PANGO_WRAP_WORD_CHAR - osd.alignment = aosd.PANGO_ALIGN_LEFT - osd.set_layout_width(osd.get_screen_wrap_width()) - return osd - - def set_string(self, osd, text): - osd.set_text(text) - return osd.get_text_size() - - def setup_config(self): - module_config = ConfigParser.RawConfigParser() - try: - module_config.read('/usr/MythVantage/etc/msg.cfg') - except: - pass - return module_config - - - - def display (self,flags): - """ - parse the msg for display. - """ - try: - text,config_section=flags.split("|") - if config_section == '': - config_section="default" - except: - text=flags - config_section="default" - - module_config = self.setup_config() - - display_time=5000 - position=6 - font_color="green" - font_type="Times New Roman Italic 36" - try: - display_time = int(module_config.get(config_section,"display_time")) - except: - pass - try: - position = int(module_config.get(config_section,"position")) - except: - pass - try: - font_color = module_config.get(config_section,"font_color") - except: - pass - try: - font_type = module_config.get(config_section,"font_type") - except: - pass - - #this bit of code converts a \n to EOL/BREAK - textline=text.split('\\n') - try: - textline.remove(' ') - except: - pass - text=chr(10).join(textline) - - #cmd = sub_process.Popen("/usr/bin/wall %s" % text,stdout=sub_process.PIPE,shell=True) - #data = cmd.communicate()[0] - osd = self.setup(font_color, font_type) - width, height = self.set_string(osd, text) - self.scroll(osd, width, height, display_time, position) - - return ("Message delivered") - - - - -def main(): - try: - opts, args = getopt.getopt(sys.argv[1:], "hm:", ["help", "msg="]) - except getopt.GetoptError, err: - # print help information and exit: - print str(err) # will print something like "option -a not recognized" - usage() - sys.exit(2) - in_msg = None - - for o, a in opts: - if o in ("-h", "--help"): - usage() - sys.exit() - elif o in ("-m", "--msg"): - in_msg = a - else: - assert False, "unhandled option" - txt_msg=in_msg - out_msg=msg() - - out_msg.display(txt_msg) - -if __name__ == "__main__": - main() - - -- cgit v0.12