cs01 / pyxtermjs Goto Github PK
View Code? Open in Web Editor NEWA fully functional terminal in your browser.
License: MIT License
A fully functional terminal in your browser.
License: MIT License
>python3 -m pyxtermjs -p 443
serving on http://127.0.0.1:443
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/klk/.local/lib/python3.6/site-packages/pyxtermjs/__main__.py", line 5, in <module>
exit(main())
File "/home/klk/.local/lib/python3.6/site-packages/pyxtermjs/app.py", line 123, in main
socketio.run(app, debug=args.debug, port=args.port, host=args.host)
File "/home/klk/.local/lib/python3.6/site-packages/flask_socketio/__init__.py", line 584, in run
self.wsgi_server.serve_forever()
File "/usr/local/lib/python3.6/dist-packages/gevent/baseserver.py", line 360, in serve_forever
self.start()
File "/usr/local/lib/python3.6/dist-packages/gevent/baseserver.py", line 304, in start
self.init_socket()
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 1451, in init_socket
StreamServer.init_socket(self)
File "/usr/local/lib/python3.6/dist-packages/gevent/server.py", line 127, in init_socket
self.socket = self.get_listener(self.address, self.backlog, self.family)
File "/usr/local/lib/python3.6/dist-packages/gevent/server.py", line 138, in get_listener
return _tcp_listener(address, backlog=backlog, reuse_addr=cls.reuse_addr, family=family)
File "/usr/local/lib/python3.6/dist-packages/gevent/server.py", line 228, in _tcp_listener
sock.bind(address)
TypeError: an integer is required (got type str)
parser.add_argument("-p", "--port", default=5000, help="port to run server on")
should add `type=int`
I am trying to save the user prompt to a log file but this program receives every key that is pressed by user without filtering any. Is there any way to save only the input when pressed enter?
Maybe this issue can keep a long-term activity status without being closed for accepting more good use scenarios.
Thank you for this awesome tool. Is there a straight-forward way to integrate the sound output of Terminal Applications running on pyxtermjs through the browser? Thank you again.
Hi Chad,
We are using a similar xtermjs application using node js (node-pty) to host the terminal process and SignalR for communication with the web host. I’ve been looking at doing the same thing using python for about a year (!) until I came across pyxtermjs and was super existed.
I’m not a python guru by any means, but I got most of it working, but I got stuck on the initiation where I run into some issues which seems related to threading.
What would it take to get an hour of your time to see if you can point me in the right direction? I’m not looking for a free-bee. I’m happy to reimburse you since I’m really stuck right now.
You can reach me a mikael dot hakansson at axians dot com. or on twitter @wmmihaa
Cheers
Mikael
I'd like a command-line argument that lets me specify a custom CSS file to use. For example, I might want to use some CSS that changes the way that the connected/disconnected looks, or I might want to specify a specific font for part of it.
Can a feature please be added to support adding custom CSS into pyxter.js?
pyxterm.js uses flask+flask-socketio on the backend. To get new output from the pty, it runs socketio.sleep() and checks for new output in an endless loop.
It would be better if it could use async+await to immediately forward the new output over a websocket. The new async web framework Bocadillo would be a good alternative to try since it now has websocket support bocadilloproject/bocadillo#75.
I'm in a situation where I have to create child pty fork for each user session. I exactly followed your approach and it's working great but text delay (while on emitting the pty output) happens if more than 3 sessions got opened (in the background it created three child processes). Please help me to overcome this situation. Does making use of async func would help? or do we have to use any low level functions like os.wait()
or os.waitpid()
?
Hi guys,
thanks for this amazing tool,
I wanted to integrate pyxtermjs on an existing python script already using flask (to avoid to use a reverse proxy using 2 ports)
Is there a simple way for this integration?
Many thanks
I'm running pyxtermjs on port 5002 and it works fine in this link
http://localhost:5002
I'm using nginx to proxy port 8083 to port 5002, to be able to access to terminal from port 8083
http://localhost:8083
But here the connection is blocked and it shows this
ERROR (_log_error_once:720) http://localhost:8083 is not an accepted origin. (further occurrences of this error will be logged with level INFO)
I guess it is blocking connections from other ports as a security feature. Is there any way to allow this ?
It is good to have customization of serve port
The purpose of this issue is to address the ability to port over to another flask application that I have been building. Currently if pyxtermjs is run with the following command the application works just fine.
python3 app.py
However when run under flask with the command "flask run" the application looses the interactivity with the shell session.
I am wondering why this is and how someone can go through and add/take-away from this base example to include it in an already existing flask application.
Why terminal is not autosized by window size? What is the reason for this behavior?
Thanks for your great work now I am trying to learn and build something cool based on your project.
And now I am facing a problem that I can not solve myself after doing a lot researches...
Let's say the starting path is /User/Example/App
and then the command input sequence from web side is :
cd ..
cd ..
And now the current path should be at /User
but how can I get this path using code ?
Any advice will be appreciated, thanks :)
Hello
I need to implement a web terminal base on flask and use the factory mode to start up the app.
My question is what time the pty.fork() function child_pid equal zero
?
your code
(child_pid, fd) = pty.fork()
if child_pid == 0:
# this is the child process fork.
# anything printed here will show up in the pty, including the output
# of this subprocess
subprocess.run(app.config["cmd"])
else:
# this is the parent process fork.
# store child fd and pid
app.config["fd"] = fd
app.config["child_pid"] = child_pid
set_winsize(fd, 50, 50)
cmd = " ".join(shlex.quote(c) for c in app.config["cmd"])
print("child pid is", child_pid)
print(
f"starting background task with command `{cmd}` to continously read "
"and forward pty output to client"
)
socketio.start_background_task(target=read_and_forward_pty_output)
print("task started")
In my application, I can't launch the subprocess.
If not have authentication, it will make a great security risk.
following install directions, pip install -r requirements, got error
Could not find a version that satisfies the requirement pkg-resources==0.0.0 (from -r requirements.txt (line 7)) (from versions: )
No matching distribution found for pkg-resources==0.0.0 (from -r requirements.txt (line 7))
Fixed by removing line pkg-resources==0.0.0 from requirements.txt
Tried this on windows 7 and it says no module named 'termios'.
Getting the same error while importing in seperate py file. Also cant install via pip when further researched it is found : no distribution available for windows
so for the time it is safe to say that this package is only linux supportive?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.