python curses
来源:互联网 发布:mac命令行终端 颜色 编辑:程序博客网 时间:2024/05/18 00:26
#!/usr/bin/env pythonfrom os import systemimport cursesdef get_param(prompt_string): screen.clear() screen.border(0) screen.addstr(2, 2, prompt_string) screen.refresh() input = screen.getstr(10, 10, 60) return inputdef execute_cmd(cmd_string): system("clear") a = system(cmd_string) print "" if a == 0: print "Command executed correctly" else: print "Command terminated with error" raw_input("Press enter") print "" x = 0
while x != ord('4'):
screen = curses.initscr() screen.clear() screen.border(0) screen.addstr(2, 2, "Please enter a number...") screen.addstr(4, 4, "1 - Add a user") screen.addstr(5, 4, "2 - Restart Apache") screen.addstr(6, 4, "3 - Show disk space") screen.addstr(7, 4, "4 - Exit") screen.refresh() x = screen.getch() if x == ord('1'): username = get_param("Enter the username") homedir = get_param("Enter the home directory, eg /home/nate") groups = get_param("Enter comma-separated groups, eg adm,dialout,cdrom") shell = get_param("Enter the shell, eg /bin/bash:") curses.endwin() execute_cmd("useradd -d " + homedir + " -g 1000 -G " + groups + " -m -s " + shell + " " + username) if x == ord('2'): curses.endwin() execute_cmd("apachectl restart") if x == ord('3'): curses.endwin() execute_cmd("df -h")curses.endwin()
0 0
- Python Curses
- Python Curses
- python curses
- Python-curses使用
- 可爱的 Python:Curses 编程
- python的curses模块使用
- curses
- curses
- curses
- curses
- curses
- curses
- python curses addrstr中文乱码问题
- win10安装Python扩展库curses
- 用python实现客户端的设想(curses、Tkinter)
- python命令行终端下操作界面库(curses,urwid,npyscreen)
- Python で Curses プログラミング
- win7平台上python不能运行curses?--已解决
- 关于Myeclipse报错的问题:An error occurred while filtering resources
- Java复习--接口、代理
- Mac下Sublime Text3配置Python开发环境
- 【TIP_4】Intent传递对象,在Activity和Fragment中再获取是否为新对象
- 汇编 org
- python curses
- 裸机(Bare Metal)安装CoreOS
- eclipse 添加resin3.1.12
- 正则表达式入门教程(三)
- 亚像素级角点定位算法
- ios推送消息 p12转pem证书 用于百度推送
- java调用ws服务
- wifi网络接入原理(下)——关联Association
- win8.1 无法安装 net framework3.5 问题的解决方法