Skip to content

Commit

Permalink
New -w/--width and -H/--height options
Browse files Browse the repository at this point in the history
  • Loading branch information
fgallaire committed Aug 8, 2016
1 parent 6569507 commit f91a552
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
25 changes: 14 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,20 @@ Commandline usage
usage: achilterm [options]

options:
-h, --help show this help message and exit
-pPORT, --port=PORT Set the TCP port (default: 8022)
-cCMD, --command=CMD set the command (default: /bin/login or ssh localhost)
-l, --log log requests to stderr (default: quiet mode)
-d, --daemon run as daemon in the background
-PPIDFILE, --pidfile=PIDFILE
set the pidfile (default: /var/run/achilterm.pid)
-iINDEX_FILE, --index=INDEX_FILE
default index file (default: achilterm.html)
-uUID, --uid=UID Set the daemon's user id
-L, --lite use Achiltermlite
--version show program's version number and exit
-h, --help show this help message and exit
-p PORT, --port=PORT set the TCP port (default: 8022)
-c CMD, --command=CMD set the command (default: /bin/login or ssh localhost)
-l, --log log requests to stderr (default: quiet mode)
-d, --daemon run as daemon in the background
-P PIDFILE, --pidfile=PIDFILE
set the pidfile (default: /var/run/achilterm.pid)
-i INDEX_FILE, --index=INDEX_FILE
default index file (default: achilterm.html)
-u UID, --uid=UID set the daemon's user id
-L, --lite use Achiltermlite
-w WIDTH, --width=WIDTH set the width (default: 80)
-H HEIGHT, --height=HEIGHT set the height (default: 25)

Configuration example
---------------------
Expand Down
16 changes: 10 additions & 6 deletions achilterm.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH achilterm "1" "August 2016" "achilterm 0.20" "User commands"
.TH achilterm "1" "August 2016" "achilterm 0.21" "User commands"
.SH NAME
Achilterm \- Web based terminal written in python

Expand All @@ -15,11 +15,15 @@ It can use almost any web browser and even works through firewalls.

.SH OPTIONS
A summary of the options supported by \fBachilterm\fR is included below:
\fB-h, --help\fR show this help message and exit
\fB-pPORT, --port=PORT\fR Set the TCP port (default: 8022)
\fB-cCMD, --command=CMD\fR set the command (default: /bin/login or ssh localhost)
\fB-l, --log\fR log requests to stderr (default: quiet mode)
\fB-L, --lite\fR use Achiltermlite
\fB--version\fR show program's version number and exit
\fB-h, --help\fR show this help message and exit
\fB-p PORT, --port=PORT\fR set the TCP port (default: 8022)
\fB-c CMD, --command=CMD\fR set the command (default: /bin/login or ssh localhost)
\fB-l, --log\fR log requests to stderr (default: quiet mode)
\fB-d, --daemon\fR run as daemon in the background
\fB-L, --lite\fR use Achiltermlite
\fB-w WIDTH, --width=WIDTH\fR set the width (default: 80)
\fB-H HEIGHT, --height=HEIGHT\fR set the height (default: 25)

.SH AUTHOR
Florent Gallaire <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion achilterm/achilterm.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script type="text/javascript" src="achilterm.js"></script>
<script type="text/javascript">
window.onload=function() {
t=achilterm.Terminal("term",80,25);
t=achilterm.Terminal("term",%(width)s,%(height)s);
};
</script>
</head>
Expand Down
16 changes: 9 additions & 7 deletions achilterm/achilterm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

__version__ = '0.20'
__version__ = '0.21'

import array,cgi,fcntl,glob,mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd

Expand Down Expand Up @@ -488,15 +488,15 @@ def loop(self):
pass

class AchilTerm:
def __init__(self,cmd=None,index_file='achilterm.html',lite=False):
def __init__(self,cmd=None,index_file='achilterm.html',lite=False,width=80,height=25):
os.chdir(os.path.normpath(os.path.dirname(__file__)))
if lite:
index_file = 'achiltermlite.html'
self.files={}
for i in ['css','html','js']:
for j in glob.glob('*.%s'%i):
self.files[j]=open(j).read()
self.files['index']=open(index_file).read()
self.files['index']=open(index_file).read() % {'width': width, 'height': height}
self.mime = mimetypes.types_map.copy()
self.mime['.html']= 'text/html; charset=UTF-8'
self.multi = Multiplex(cmd)
Expand Down Expand Up @@ -552,14 +552,16 @@ def log_message(self, format, *args):

def main():
parser = optparse.OptionParser(version='Achilterm version ' + __version__)
parser.add_option("-p", "--port", dest="port", default="8022", help="Set the TCP port (default: 8022)")
parser.add_option("-p", "--port", dest="port", default="8022", help="set the TCP port (default: 8022)")
parser.add_option("-c", "--command", dest="cmd", default=None,help="set the command (default: /bin/login or ssh localhost)")
parser.add_option("-l", "--log", action="store_true", dest="log",default=0,help="log requests to stderr (default: quiet mode)")
parser.add_option("-d", "--daemon", action="store_true", dest="daemon", default=0, help="run as daemon in the background")
parser.add_option("-P", "--pidfile",dest="pidfile",default="/var/run/achilterm.pid",help="set the pidfile (default: /var/run/achilterm.pid)")
parser.add_option("-i", "--index", dest="index_file", default=0, help="default index file (default: achilterm.html)")
parser.add_option("-u", "--uid", dest="uid", help="Set the daemon's user id")
parser.add_option("-u", "--uid", dest="uid", help="set the daemon's user id")
parser.add_option("-L", "--lite", action="store_true", dest="lite", default=0, help="use Achiltermlite")
parser.add_option("-w", "--width", dest="width", default="80", help="set the width (default: 80)")
parser.add_option("-H", "--height", dest="height", default="25", help="set the height (default: 25)")
(o, a) = parser.parse_args()
if o.daemon:
pid=os.fork()
Expand Down Expand Up @@ -590,9 +592,9 @@ def main():
else:
handler_class = NoLogWSGIRequestHandler
if o.index_file:
at=AchilTerm(o.cmd,os.path.abspath(o.index_file),o.lite)
at=AchilTerm(o.cmd,os.path.abspath(o.index_file),o.lite,o.width,o.height)
else:
at=AchilTerm(o.cmd,lite=o.lite)
at=AchilTerm(o.cmd,lite=o.lite,width=o.width,height=o.height)
try:
make_server('localhost', int(o.port), at, handler_class=handler_class).serve_forever()
except KeyboardInterrupt:
Expand Down
2 changes: 1 addition & 1 deletion achilterm/achiltermlite.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script type="text/javascript" src="achiltermlite.js"></script>
<script type="text/javascript">
window.onload=function() {
t=achilterm.Terminal("term",80,25);
t=achilterm.Terminal("term",%(width)s,%(height)s);
};
</script>
</head>
Expand Down

0 comments on commit f91a552

Please sign in to comment.