Skip to content

Commit 1bfd067

Browse files
committed
Merge branch 'release/0.1.1' into main
2 parents afd8481 + 14e4601 commit 1bfd067

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.1.1] - 2021-02-14
11+
12+
### Fixed
13+
14+
- Now raises an error when the `socat` binary cannot be found ([#1](https://github.com/chvolkmann/code-connect/pull/1))
15+
1016
## [0.1.0] - 2021-02-13
1117

1218
### Added
1319

1420
- Initial release of `code-connect` and the corresponding fish plugin
1521

16-
[unreleased]: https://github.com/chvolkmann/code-connect/compare/latest...HEAD
22+
[unreleased]: https://github.com/chvolkmann/code-connect/compare/v0.1.1...HEAD
23+
[0.1.1]: https://github.com/chvolkmann/code-connect/compare/v0.1.0...v0.1.1
1724
[0.1.0]: https://github.com/chvolkmann/code-connect/releases/tag/v0.1.0

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ This utility enables you to call `code .` instead, just as you would in a WSL se
1313

1414
### Requirements
1515

16-
Requires Python 3 and a **Linux** machine you want to connect to. Tested under Python 3.8, but slightly lower should work fine.
16+
- a **Linux machine** you want to run `code-connect` on
17+
- **Python 3** - _tested under Python 3.8, but slightly older versions should work fine_
18+
- **socat** - used for pinging UNIX sockets
19+
```bash
20+
apt-get install socat
21+
```
1722

1823
### VS Code Server
1924

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0
1+
0.1.1

code_connect.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
# based on https://stackoverflow.com/a/60949722
44

5-
from pathlib import Path
6-
import subprocess as sp
7-
from typing import Iterable, List, Tuple
85
import time
6+
import subprocess as sp
97
import os
8+
from distutils.spawn import find_executable
9+
from typing import Iterable, List, Tuple
10+
from pathlib import Path
1011

1112
MAX_IDLE_TIME = 4 * 60 * 60
1213

@@ -38,7 +39,15 @@ def next_open_socket(socks: Iterable[Path]) -> Path:
3839
'Please make sure to connect to this machine with a standard VS Code remote SSH session before using this tool.'
3940
)
4041

42+
def check_for_binaries():
43+
if find_executable('socat') is None:
44+
fail(
45+
'"socat" not found in $PATH, but is required for code-connect'
46+
)
47+
4148
def main(shell: str = None, max_idle_time: int = MAX_IDLE_TIME):
49+
check_for_binaries()
50+
4251
# Determine shell for outputting the proper format
4352
if not shell:
4453
shell = os.getenv('SHELL', 'bash')
@@ -62,9 +71,10 @@ def main(shell: str = None, max_idle_time: int = MAX_IDLE_TIME):
6271

6372
code_binary = code_repo / 'bin' / 'code'
6473

65-
# List all possible sockets
74+
# List all possible sockets for the current user
6675
# Some of these are obsolete and not listening
67-
socks = sort_by_access_timestamp(Path('/run/user/1000/').glob('vscode-ipc-*.sock'))
76+
uid = os.getuid()
77+
socks = sort_by_access_timestamp(Path(f'/run/user/{uid}/').glob('vscode-ipc-*.sock'))
6878

6979
# Only consider the ones that were active N seconds ago
7080
now = time.time()

0 commit comments

Comments
 (0)