GIF89a=( �' 7IAXKgNgYvYx\%wh&h}t�h%�s%x�}9�R��&�0%� (�.��5�SD��&�a)�x5��;ͣ*ȡ&ղ)ׯ7׵<ѻ4�3�H֧KͯT��Y�aq��q��F� !� ' !� NETSCAPE2.0 , =( ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g���E�������R���E����B�� ��ȸ��D���"�Ů� �H��L��D٫D�B�����D���T���H �G��A R�ڐ |�� ٭&��E8�S�kG�A�px�a��� R2XB��E8I���6X�:vT)�~��q�賥��"F~%x� � 4#Z�0O|-4Bs�X:= Q� Sal��yXJ`GȦ|s h��K3l7�B|�$'7Jީܪ0!��D�n=�P� ����0`�R�lj����v>���5 �.69�ϸd�����nlv�9��f{���Pbx �l5}�p� ��� �3a���I�O����!ܾ���i��9��#��)p�a ޽ �{�)vm��%D~ 6f��s}Œ�D�W E�`!� �&L8x� �ܝ{)x`X/>�}m��R�*|`D�=�_ ^�5 !_&'a�O�7�c��`DCx`�¥�9�Y�F���`?��"� �n@`�} lď��@4>�d S �v�xN��"@~d��=�g�s~G��� ���ud &p8Q�)ƫlXD����A~H�ySun�j���k*D�LH�] ��C"J��Xb~ʪwSt}6K,��q�S:9ت:���l�@�`�� �.۬�t9�S�[:��=`9N����{¿�A !R�:���6��x�0�_ �;������^���#����!����U���;0L1�����p% A��U̬ݵ��%�S��!���~`�G���� ���=4�np�3���������u�u�ٮ|%2�I��r�#0��J``8�@S@5� ���^`8E�]�.�S���7 � �0�j S�D� z���i�S�����!���l��w9*�D�I�nEX��� &A�Go�Qf��F��;���}�J����F5��Q|���X��T��y���]� o ��C=��:���PB@ D׽S�(>�C�x}`��xJЬ�۠��p+eE0`�}`A �/NE�� �9@��� H�7�!%B0`�l*��!8 2�%� �:�1�0E��ux%nP1�!�C)�P81l�ɸF#Ƭ{����B0>�� �b�`��O3��()yRpb��E.ZD8�H@% �Rx+%���c� ���f��b�d�`F�"8�XH"��-�|1�6iI, 2�$+](A*j� QT�o0.�U�`�R�}`�SN����yae�����b��o~ S)�y�@��3 �tT�0�&�+~L�f"�-|�~��>!�v��~�\Q1)}@�}h#aP72�"�$ !� " , =( &7IAXG]KgNgYvYxR"k\%w]'}h}t�h%�g+�s%r.m3ax3�x�}9��&��+�!7�0%� (�.�SD��&��;�"&ײ)׻4��6�K� �@pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E �� �������E �´��C���ǶR��D��"Ʒ�ʱH��M��GڬD�B����D��T����G���C�C� l&�~:'�tU�6ɹ#��)�'�.6�&��Ȼ K(8p0N�?!�2"��NIJX>R��OM '��2�*x�>#n� �@<[:�I�f ��T���Cdb��[�}E�5MBo��@�`@��tW-3 �x�B���jI�&E�9[T&$��ﯧ&"s��ȳ����dc�UUρ#���ldj?����`\}���u|3'�R]�6 �S#�!�FKL�*N E���`$�:e�YD�q�.�촁�s \-�jA 9�����-��M[�x(�s��x�|���p��}k�T�DpE@W� ��]k`1� ���Yb ��0l��*n0��"~zBd�~u�7�0Bl��0-�x~|U�U0 �h�*HS�|��e"#"?vp�i`e6^�+q��`m8 #V�� ��VS|`��"m"сSn|@:U���~`pb�G�ED����2F�I�? >�x� R� ��%~jx��<�a�9ij�2�D��&: Z`�]w���:�6��B�7eFJ|�ҧ�,���FǮcS�ʶ+B�,�ܺN���>PAD�HD��~���n��}�#�� Q��S���2�X�{�k�lQ�2�����w�|2� h9��G�,m���3��6-��E�L��I�³*K���q�`DwV�QXS��peS��� qܧTS����R�u �<�a�*At�lmE� � ��N[P1�ۦ��$��@`��Dpy�yXvCAy�B`}D� 0QwG#� �a[^�� $���Ǧ{L�"[��K�g�;�S~��GX.�goT.��ư��x���?1z��x~:�g�|�L� ��S`��0S]P�^p F<""�?!,�!N4&P� ����:T�@h�9%t��:�-~�I<`�9p I&.)^ 40D#p@�j4�ج:�01��rܼF2oW�#Z ;$Q q  �K��Nl#29 !F@�Bh�ᏬL!XF�LHKh�.�hE&J�G��<"WN!�����Y@� >R~19J"�2,/ &.GXB%�R�9B6�W]���W�I�$��9�RE8Y� ��"�A5�Q.axB�&ة�J�! �t)K%tS-�JF b�NMxL��)�R��"���6O!TH�H� 0 !� ) , =( &AXKgNgYvYxR"k\%wh&h}h%�g+�s%r.x3�x�}9��&��+�R,�!7�0%� (�.��5��&�a)��;�"&ף*Ȳ)ׯ7׻4�3��6�H֧KͻH�T��Y��q��h� ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E$����� � ����$E$��"��D� � ������R��C��� E ��H�M��G�D� �B��ϾD��a��`1r��Ӑ�� �o~�zU!L�C'�yW�UGt����ll�0���uG�)A�s[��x� �xO%��X2�  P�n:R/��aHae+�Dm?# ǣ6�8�J�x�Di�M���j���5oQ7�- <! *�l��R2r/a!l)d� A"�E���� &� ;��c �%����b��pe~C"B���H�eF2��`8qb�t_`ur`e� w�u3��Pv�h""�`�Íx�LĹ��3� �~ֺ�:���MDfJ� �۵�W�%�S�X �؁)�@��:E��w�u�Sxb8y\m�zS��Zb�E�L��w!y(>�"w�=�|��s�d �C�W)H�cC$�L �7r.�\{)@�`@ �X�$PD `aaG:���O�72E�amn]�"Rc�x�R� &dR8`g��i�xLR!�P &d����T���i�|�_ � Qi�#�`g:��:noM� :V �)p����W&a=�e�k� j���1߲s�x�W�jal|0��B0�, \j۴:6���C ��W��|��9���zĸV {�;��n��V�m�I��.��PN� ����C��+��By�ѾHŸ:��� 7�Y�FTk�SaoaY$D�S���29R�kt� ��f� ��:��Sp�3�I��DZ� �9���g��u�*3)O��[_hv ,���Et x�BH� �[��64M@�S�M7d�l�ܶ5-��U܍��z�R3Ԭ3~ ��P��5�g: ���kN�&0�j4���#{��3S�2�K�'ợl���2K{� {۶?~m𸧠�I�nE�='����^���_�=��~�#O���'���o..�Y�n��CSO��a��K��o,���b�����{�C�� "�{�K ��w��Ozdը�:$ ���v�] A#� ���a�z)Rx׿ƥ�d``�w-�y�f�K!����|��P��=�`�(f��'Pa ��BJa%��f�%`�}F����6>��`G"�}�=�!o`�^FP�ةQ�C���`(�}\�ݮ ��$<��n@dĠE#��U�I�!� #l��9`k���'Rr��Z�NB�MF �[�+9���-�wj���8�r� ,V�h"�|�S=�G_��"E� 0i*%̲��da0mVk�):;&6p>�jK ��# �D�:�c?:R Ӭf��I-�"�<�="��7�3S��c2RW ,�8(T"P0F¡Jh�" ; 403WebShell
403Webshell
Server IP : 173.249.157.85  /  Your IP : 3.148.108.24
Web Server : Apache
System : Linux server.frogzhost.com 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64
User : econtech ( 1005)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/dialog-1.2/samples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/doc/dialog-1.2/samples/dialog.py
#!/usr/bin/python
# $Id: dialog.py,v 1.4 2012/06/29 09:33:18 tom Exp $
# Module: dialog.py
# Copyright (c) 2000 Robb Shecter <robb@acm.org>
# All rights reserved.
# This source is covered by the GNU GPL.
#
# This module is a Python wrapper around the Linux "dialog" utility
# by Savio Lam and Stuart Herbert.  My goals were to make dialog as
# easy to use from Python as possible.  The demo code at the end of
# the module is a good example of how to use it.  To run the demo,
# execute:
#
#                       python dialog.py
#
# This module has one class in it, "Dialog".  An application typically
# creates an instance of it, and possibly sets the background title option.
# Then, methods can be called on it for interacting with the user.
#
# I wrote this because I want to use my 486-33 laptop as my main
# development computer (!), and I wanted a way to nicely interact with the
# user in console mode.  There are apparently other modules out there
# with similar functionality, but they require the Python curses library.
# Writing this module from scratch was easier than figuring out how to
# recompile Python with curses enabled. :)
#
# One interesting feature is that the menu and selection windows allow
# *any* objects to be displayed and selected, not just strings.
#
# TO DO:
#   Add code so that the input buffer is flushed before a dialog box is
#     shown.  This would make the UI more predictable for users.  This
#     feature could be turned on and off through an instance method.
#   Drop using temporary files when interacting with 'dialog'
#     (it's possible -- I've already tried :-).
#   Try detecting the terminal window size in order to make reasonable
#     height and width defaults.  Hmmm - should also then check for 
#     terminal resizing...
#   Put into a package name to make more reusable - reduce the possibility
#     of name collisions.
#
# NOTES:
#         there is a bug in (at least) Linux-Mandrake 7.0 Russian Edition
#         running on AMD K6-2 3D that causes core dump when 'dialog' 
#         is running with --gauge option;
#         in this case you'll have to recompile 'dialog' program.
#
# Modifications:
# Jul 2000, Sultanbek Tezadov (http://sultan.da.ru)
#    Added:
#       - 'gauge' widget *)
#       - 'title' option to some widgets
#       - 'checked' option to checklist dialog; clicking "Cancel" is now
#           recognizable
#       - 'selected' option to radiolist dialog; clicking "Cancel" is now
#           recognizable
#       - some other cosmetic changes and improvements
#   

import os
from tempfile import mktemp
from string import split
from time import sleep

#
# Path of the dialog executable
#
DIALOG = os.getenv("DIALOG");
if DIALOG is None:
	DIALOG="../dialog";

class Dialog:
    def __init__(self):
	self.__bgTitle = ''               # Default is no background title


    def setBackgroundTitle(self, text):
	self.__bgTitle = '--backtitle "%s"' % text


    def __perform(self, cmd):
	"""Do the actual work of invoking dialog and getting the output."""
	fName = mktemp()
	rv = os.system('%s %s %s 2> %s' % (DIALOG, self.__bgTitle, cmd, fName))
	f = open(fName)
	output = f.readlines()
	f.close()
	os.unlink(fName)
	return (rv, output)


    def __perform_no_options(self, cmd):
	"""Call dialog w/out passing any more options. Needed by --clear."""
	return os.system(DIALOG + ' ' + cmd)


    def __handleTitle(self, title):
	if len(title) == 0:
	    return ''
	else:
	    return '--title "%s" ' % title


    def yesno(self, text, height=10, width=30, title=''):
	"""
	Put a Yes/No question to the user.
	Uses the dialog --yesno option.
	Returns a 1 or a 0.
	"""
	(code, output) = self.__perform(self.__handleTitle(title) +\
	    '--yesno "%s" %d %d' % (text, height, width))
	return code == 0


    def msgbox(self, text, height=10, width=30, title=''):
	"""
	Pop up a message to the user which has to be clicked
	away with "ok".
	"""
	self.__perform(self.__handleTitle(title) +\
	    '--msgbox "%s" %d %d' % (text, height, width))


    def infobox(self, text, height=10, width=30):
	"""Make a message to the user, and return immediately."""
	self.__perform('--infobox "%s" %d %d' % (text, height, width))


    def inputbox(self, text, height=10, width=30, init='', title=''):
	"""
	Request a line of input from the user.
	Returns the user's input or None if cancel was chosen.
	"""
	(c, o) = self.__perform(self.__handleTitle(title) +\
	    '--inputbox "%s" %d %d "%s"' % (text, height, width, init))
	try:
	    return o[0]
	except IndexError:
	    if c == 0:  # empty string entered
		return ''
	    else:  # canceled
		return None


    def textbox(self, filename, height=20, width=60, title=None):
	"""Display a file in a scrolling text box."""
	if title is None:
	    title = filename
	self.__perform(self.__handleTitle(title) +\
	    ' --textbox "%s" %d %d' % (filename, height, width))


    def menu(self, text, height=15, width=54, list=[]):
	"""
	Display a menu of options to the user.  This method simplifies the
	--menu option of dialog, which allows for complex arguments.  This
	method receives a simple list of objects, and each one is assigned
	a choice number.
	The selected object is returned, or None if the dialog was canceled.
	"""
	menuheight = height - 8
	pairs = map(lambda i, item: (i + 1, item), range(len(list)), list)
	choices = reduce(lambda res, pair: res + '%d "%s" ' % pair, pairs, '')
	(code, output) = self.__perform('--menu "%s" %d %d %d %s' %\
	    (text, height, width, menuheight, choices))
	try:
	    return list[int(output[0]) - 1]
	except IndexError:
	    return None


    def checklist(self, text, height=15, width=54, list=[], checked=None):
	"""
	Returns a list of the selected objects.
	Returns an empty list if nothing was selected.
	Returns None if the window was canceled.
	checked -- a list of boolean (0/1) values; len(checked) must equal 
	    len(list).
	"""
	if checked is None:
	    checked = [0]*len(list)
	menuheight = height - 8
	triples = map(
	    lambda i, item, onoff, fs=('off', 'on'): (i + 1, item, fs[onoff]),
	    range(len(list)), list, checked)
	choices = reduce(lambda res, triple: res + '%d "%s" %s ' % triple,
	    triples, '')
	(c, o) = self.__perform('--checklist "%s" %d %d %d %s' %\
	    (text, height, width, menuheight, choices))
	try:
	    output = o[0]
	    indexList  = map(lambda x: int(x[1:-1]), split(output))
	    objectList = filter(lambda item, list=list, indexList=indexList: 
		    list.index(item) + 1 in indexList,
		list)
	    return objectList
	except IndexError:
	    if c == 0:                        # Nothing was selected
		return []
	    return None  # Was canceled


    def radiolist(self, text, height=15, width=54, list=[], selected=0):
	"""
	Return the selected object.
	Returns empty string if no choice was selected.
	Returns None if window was canceled.
	selected -- the selected item (must be between 1 and len(list)
	    or 0, meaning no selection).
	"""
	menuheight = height - 8
	triples = map(lambda i, item: (i + 1, item, 'off'),
	    range(len(list)), list)
	if selected:
	    i, item, tmp = triples[selected - 1]
	    triples[selected - 1] = (i, item, 'on')
	choices = reduce(lambda res, triple: res + '%d "%s" %s ' % triple,
	    triples, '')
	(c, o) = self.__perform('--radiolist "%s" %d %d %d %s' %\
	    (text, height, width, menuheight, choices))
	try:
	    return list[int(o[0]) - 1]
	except IndexError:
	    if c == 0:
		return ''
	    return None
 

    def clear(self):
	"""
	Clear the screen. Equivalent to the dialog --clear option.
	"""
	self.__perform_no_options('--clear')


    def scrollbox(self, text, height=20, width=60, title=''):
	"""
	This is a bonus method.  The dialog package only has a function to
	display a file in a scrolling text field.  This method allows any
	string to be displayed by first saving it in a temp file, and calling
	--textbox.
	"""
	fName = mktemp()
	f = open(fName, 'w')
	f.write(text)
	f.close()
	self.__perform(self.__handleTitle(title) +\
	    '--textbox "%s" %d %d' % (fName, height, width))
	os.unlink(fName)


    def gauge_start(self, perc=0, text='', height=8, width=54, title=''):
	"""
	Display gauge output window.
	Gauge normal usage (assuming that there is an instace of 'Dialog'
	class named 'd'):
	    d.gauge_start()
	    # do something
	    d.gauge_iterate(10)  # passed throgh 10%
	    # ...
	    d.gauge_iterate(100, 'any text here')  # work is done
	    d.stop_gauge()  # clean-up actions
	"""
	cmd = self.__handleTitle(title) +\
	    '--gauge "%s" %d %d %d' % (text, height, width, perc)
	cmd = '%s %s %s 2> /dev/null' % (DIALOG, self.__bgTitle, cmd)
	self.pipe = os.popen(cmd, 'w')
    #/gauge_start()


    def gauge_iterate(self, perc, text=''):
	"""
	Update percentage point value.
	
	See gauge_start() function above for the usage.
	"""
	if text:
	    text = 'XXX\n%d\n%s\nXXX\n' % (perc, text)
	else:
	    text = '%d\n' % perc
	self.pipe.write(text)
	self.pipe.flush()
    #/gauge_iterate()
    
    
    def gauge_stop(self):
	"""
	Finish previously started gauge.
	
	See gauge_start() function above for the usage.
	"""
	self.pipe.close()
    #/gauge_stop()



#
# DEMO APPLICATION
#
if __name__ == '__main__':
    """
    This demo tests all the features of the class.
    """
    d = Dialog()
    d.setBackgroundTitle('dialog.py demo')

    d.infobox(
	"One moment... Just wasting some time here to test the infobox...")
    sleep(3)

    if d.yesno("Do you like this demo?"):
	d.msgbox("Excellent!  Here's the source code:")
    else:
	d.msgbox("Send your complaints to /dev/null")
    
    d.textbox("dialog.py")

    name = d.inputbox("What's your name?", init="Snow White")
    fday = d.menu("What's your favorite day of the week?", 
	list=["Monday", "Tuesday", "Wednesday", "Thursday", 
	    "Friday (The best day of all)", "Saturday", "Sunday"])
    food = d.checklist("What sandwich toppings do you like?", 
	list=["Catsup", "Mustard", "Pesto", "Mayonaise", "Horse radish", 
	    "Sun-dried tomatoes"], checked=[0,0,0,1,1,1])
    sand = d.radiolist("What's your favorite kind of sandwich?", 
	list=["Hamburger", "Hotdog", "Burrito", "Doener", "Falafel", 
	    "Bagel", "Big Mac", "Whopper", "Quarter Pounder", 
	    "Peanut Butter and Jelly", "Grilled cheese"], selected=4)

    # Prepare the message for the final window
    bigMessage = "Here are some vital statistics about you:\n\nName: " + name +\
        "\nFavorite day of the week: " + fday +\
	"\nFavorite sandwich toppings:\n"
    for topping in food:
	bigMessage = bigMessage + "    " + topping + "\n"
    bigMessage = bigMessage + "Favorite sandwich: " + str(sand)

    d.scrollbox(bigMessage)

    #<>#  Gauge Demo
    d.gauge_start(0, 'percentage: 0', title='Gauge Demo')
    for i in range(1, 101):
	if i < 50:
	    msg = 'percentage: %d' % i
	elif i == 50:
	    msg = 'Over 50%'
	else:
	    msg = ''
	d.gauge_iterate(i, msg)
	sleep(0.1)
    d.gauge_stop()
    #<>#

    d.clear()

Youez - 2016 - github.com/yon3zu
LinuXploit