Skip to content

Commit 3d8f996

Browse files
committed
pin requirements and some cleanup
1 parent 8cc4fb2 commit 3d8f996

File tree

9 files changed

+129
-110
lines changed

9 files changed

+129
-110
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## 0.5.0.0
2+
3+
* Update dependencies xtermjs and socketio
4+
* Turn off flask's logging
5+
* Update setup.py to install from pinned dependencies in requirements.tx

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
include README.md LICENSE
1+
include README.md LICENSE requirements.txt
22
recursive-include pyxtermjs *

README.md

+13-15
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,32 @@ This is a
3232
There are a few ways to install and run.
3333

3434
### Clone & Run Locally
35-
Clone this repository, enter the `pyxtermjs` directory, then run:
35+
Clone this repository, enter the `pyxtermjs` directory.
36+
37+
If you have [nox](https://github.com/theacodes/nox) you can run the following.
3638
```
37-
> python -m venv venv # must be python3.6+
38-
> venv/bin/pip install -r requirements.txt
39-
> venv/bin/python -m pyxtermjs
40-
serving on http://127.0.0.1:5000
39+
> nox -s run
4140
```
41+
Nox takes care of setting up a virtual environment and running the right command for you.
4242

43-
### Install or Run latest version on PyPI
44-
You can use [pipx](https://github.com/pipxproject/pipx) to try it out.
43+
If you don't have nox, you can run the following from inside a virtual environment.
4544
```
46-
> pipx run pyxtermjs
47-
serving on http://127.0.0.1:5000
45+
> pip install -r requirements.txt
46+
> python -m pyxtermjs
4847
```
4948

50-
You can also and have `pyxtermjs` installed in an isolated environment, yet available on your $PATH with
49+
### Install
50+
You can install with [pipx](https://github.com/pipxproject/pipx) (recommended) or pip.
5151
```
5252
> pipx install pyxtermjs
53+
> pyxtermjs
5354
```
5455

55-
### Run from GitHub source
56-
Use [pipx](https://github.com/pipxproject/pipx) for this as well.
56+
Or you can try run latest version on PyPI
5757
```
58-
> pipx run --spec git+https://github.com/cs01/pyxtermjs.git pyxtermjs
59-
serving on http://127.0.0.1:5000
58+
> pipx run pyxtermjs
6059
```
6160

62-
6361
## API
6462
```
6563
> pyxtermjs --help

noxfile.py

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
nox.options.reuse_existing_virtualenvs = True
88

99

10+
@nox.session()
11+
def run(session):
12+
session.install(".")
13+
session.run("python", "-m", "pyxtermjs", *session.posargs)
14+
15+
1016
def has_changes():
1117
status = (
1218
subprocess.run(

pyxtermjs/app.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@
1010
import struct
1111
import fcntl
1212
import shlex
13+
import logging
1314

15+
logging.getLogger("werkzeug").setLevel(logging.ERROR)
1416

15-
__version__ = "0.4.0.2"
17+
__version__ = "0.5.0.0"
1618

1719
app = Flask(__name__, template_folder=".", static_folder=".", static_url_path="")
1820
app.config["SECRET_KEY"] = "secret!"
1921
app.config["fd"] = None
2022
app.config["child_pid"] = None
21-
socketio = SocketIO(app)
23+
socketio = SocketIO(app, logger=False, engineio_logger=False)
2224

2325

2426
def set_winsize(fd, row, col, xpix=0, ypix=0):
@@ -49,8 +51,8 @@ def pty_input(data):
4951
terminal.
5052
"""
5153
if app.config["fd"]:
52-
# print("writing to ptd: %s" % data["input"])
53-
os.write(app.config["fd"], data["input"]["key"].encode())
54+
# print("writing to pty: %s" % data["input"])
55+
os.write(app.config["fd"], data["input"].encode())
5456

5557

5658
@socketio.on("resize", namespace="/pty")

pyxtermjs/index.html

+80-76
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,97 @@
11
<html lang="en">
2-
<head>
3-
<meta charset="utf-8">
4-
<title>pyxterm.js</title>
5-
<style>
6-
html {
7-
font-family: arial;
8-
}
9-
</style>
10-
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/xterm.css" />
11-
</head>
12-
<body>
2+
<head>
3+
<meta charset="utf-8" />
4+
<title>pyxterm.js</title>
5+
<style>
6+
html {
7+
font-family: arial;
8+
}
9+
</style>
10+
<link
11+
rel="stylesheet"
12+
href="https://unpkg.com/[email protected]/css/xterm.css"
13+
/>
14+
</head>
15+
<body>
16+
<span style="font-size: 1.4em">pyxterm.js</span>&nbsp;&nbsp;&nbsp;
17+
<span style="font-size: small"
18+
>status:
19+
<span style="font-size: small" id="status">connecting...</span></span
20+
>
1321

14-
<span style="font-size: 1.4em;">pyxterm.js</span>&nbsp;&nbsp;&nbsp;
15-
<span style="font-size: small;">status: <span style="font-size: small;" id="status">connecting...</span></span>
22+
<div style="width: 100%; height: calc(100% - 50px)" id="terminal"></div>
1623

17-
<div style="width: 100%; height: calc(100% - 50px);" id="terminal"></div>
18-
19-
<p style="text-align: right; font-size: small;">
20-
built by <a href="https://grassfedcode.com">Chad Smith</a> <a href="https://github.com/cs01">GitHub</a>
21-
</p>
22-
<!-- xterm -->
23-
<script src="https://unpkg.com/[email protected]/lib/xterm.js"></script>
24-
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-fit.js"></script>
25-
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-web-links.js"></script>
26-
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-sear
24+
<p style="text-align: right; font-size: small">
25+
built by <a href="https://grassfedcode.com">Chad Smith</a>
26+
<a href="https://github.com/cs01">GitHub</a>
27+
</p>
28+
<!-- xterm -->
29+
<script src="https://unpkg.com/[email protected]/lib/xterm.js"></script>
30+
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-fit.js"></script>
31+
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-web-links.js"></script>
32+
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-sear
2733
ch.js"></script>
28-
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script>
34+
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script>
2935

30-
<script>
31-
const term = new Terminal({
36+
<script>
37+
const term = new Terminal({
3238
cursorBlink: true,
3339
macOptionIsMeta: true,
3440
scrollback: true,
35-
});
36-
// https://github.com/xtermjs/xterm.js/issues/2941
37-
const fit = new FitAddon.FitAddon();
38-
term.loadAddon(fit);
39-
term.loadAddon(new WebLinksAddon.WebLinksAddon());
40-
term.loadAddon(new SearchAddon.SearchAddon());
41-
42-
term.open(document.getElementById('terminal'));
43-
fit.fit()
44-
term.resize(15, 50)
45-
console.log(`size: ${term.cols} columns, ${term.rows} rows`)
46-
fit.fit()
47-
term.write("Welcome to pyxterm.js!\nhttps://github.com/cs01/pyxterm.js\n")
48-
term.onKey((key, ev) => {
49-
console.log("pressed key", key)
50-
console.log("event", ev)
51-
socket.emit("pty-input", {"input": key})
52-
});
53-
54-
const socket = io.connect('/pty');
55-
const status = document.getElementById("status")
56-
57-
socket.on("pty-output", function(data){
58-
console.log("new output", data)
59-
term.write(data.output)
60-
})
41+
});
42+
// https://github.com/xtermjs/xterm.js/issues/2941
43+
const fit = new FitAddon.FitAddon();
44+
term.loadAddon(fit);
45+
term.loadAddon(new WebLinksAddon.WebLinksAddon());
46+
term.loadAddon(new SearchAddon.SearchAddon());
6147

62-
socket.on("connect", () => {
63-
fitToscreen()
64-
status.innerHTML = '<span style="background-color: lightgreen;">connected</span>'
65-
}
66-
)
48+
term.open(document.getElementById("terminal"));
49+
fit.fit();
50+
term.resize(15, 50);
51+
console.log(`size: ${term.cols} columns, ${term.rows} rows`);
52+
fit.fit();
53+
term.writeln("Welcome to pyxterm.js!");
54+
term.writeln("https://github.com/cs01/pyxterm.js");
55+
term.onData((data) => {
56+
console.log("pressed key", data.input);
57+
socket.emit("pty-input", { input: data.input });
58+
});
6759

68-
socket.on("disconnect", () => {
69-
status.innerHTML = '<span style="background-color: #ff8383;">disconnected</span>'
70-
})
60+
const socket = io.connect("/pty");
61+
const status = document.getElementById("status");
7162

72-
function fitToscreen(){
73-
fit.fit()
74-
socket.emit("resize", {"cols": term.cols, "rows": term.rows})
75-
}
63+
socket.on("pty-output", function (data) {
64+
console.log("new output", data);
65+
term.write(data.output);
66+
});
7667

77-
function debounce(func, wait_ms) {
78-
let timeout
79-
return function(...args) {
80-
const context = this
81-
clearTimeout(timeout)
82-
timeout = setTimeout(() => func.apply(context, args), wait_ms)
83-
}
84-
}
68+
socket.on("connect", () => {
69+
fitToscreen();
70+
status.innerHTML =
71+
'<span style="background-color: lightgreen;">connected</span>';
72+
});
8573

86-
const wait_ms = 50;
87-
window.onresize = debounce(fitToscreen, wait_ms)
74+
socket.on("disconnect", () => {
75+
status.innerHTML =
76+
'<span style="background-color: #ff8383;">disconnected</span>';
77+
});
8878

79+
function fitToscreen() {
80+
fit.fit();
81+
socket.emit("resize", { cols: term.cols, rows: term.rows });
82+
}
8983

90-
</script>
84+
function debounce(func, wait_ms) {
85+
let timeout;
86+
return function (...args) {
87+
const context = this;
88+
clearTimeout(timeout);
89+
timeout = setTimeout(() => func.apply(context, args), wait_ms);
90+
};
91+
}
9192

92-
</body>
93+
const wait_ms = 50;
94+
window.onresize = debounce(fitToscreen, wait_ms);
95+
</script>
96+
</body>
9397
</html>

requirements.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flask-socketio==5.1.1

requirements.txt

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
#
2-
# This file is autogenerated by pip-compile
2+
# This file is autogenerated by pip-compile with python 3.8
33
# To update, run:
44
#
5-
# pip-compile
5+
# pip-compile requirements.in
66
#
77
bidict==0.21.2
88
# via python-socketio
9-
click==7.1.2
9+
click==8.0.1
1010
# via flask
11-
flask-socketio==5.0.1
12-
# via pyxtermjs (setup.py)
13-
flask==1.1.2
11+
flask==2.0.1
1412
# via flask-socketio
15-
itsdangerous==1.1.0
13+
flask-socketio==5.1.1
14+
# via -r requirements.in
15+
itsdangerous==2.0.1
1616
# via flask
17-
jinja2==2.11.3
17+
jinja2==3.0.1
1818
# via flask
19-
markupsafe==1.1.1
19+
markupsafe==2.0.1
2020
# via jinja2
21-
python-engineio==4.1.0
21+
python-engineio==4.2.1
2222
# via python-socketio
23-
python-socketio==5.2.1
23+
python-socketio==5.4.0
2424
# via flask-socketio
25-
werkzeug==1.0.1
25+
werkzeug==2.0.1
2626
# via flask

setup.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from typing import List # noqa E402
1313
import ast # noqa E402
1414
import re # noqa E402
15+
import distutils.text_file
1516

1617
CURDIR = Path(__file__).parent
1718

@@ -35,7 +36,7 @@ def get_version() -> str:
3536
name="pyxtermjs",
3637
version=get_version(),
3738
author="Chad Smith",
38-
author_email="grassfedcode@gmail.com",
39+
author_email="chadsmith.software@gmail.com",
3940
description="interactive terminal in the browser",
4041
long_description=README,
4142
long_description_content_type="text/markdown",
@@ -59,7 +60,9 @@ def get_version() -> str:
5960
extras_require={},
6061
zip_safe=False,
6162
python_requires=">=3.6",
62-
install_requires=["flask-socketio>=5.0, <6.0"],
63+
install_requires=distutils.text_file.TextFile(
64+
filename="./requirements.txt"
65+
).readlines(),
6366
classifiers=[
6467
"Operating System :: OS Independent",
6568
"License :: OSI Approved :: MIT License",

0 commit comments

Comments
 (0)