Skip to content

Commit

Permalink
Merge branch 'release/0.1.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
chvolkmann committed Feb 14, 2021
2 parents afd8481 + 14e4601 commit 1bfd067
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.1] - 2021-02-14

### Fixed

- Now raises an error when the `socat` binary cannot be found ([#1](https://github.com/chvolkmann/code-connect/pull/1))

## [0.1.0] - 2021-02-13

### Added

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

[unreleased]: https://github.com/chvolkmann/code-connect/compare/latest...HEAD
[unreleased]: https://github.com/chvolkmann/code-connect/compare/v0.1.1...HEAD
[0.1.1]: https://github.com/chvolkmann/code-connect/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/chvolkmann/code-connect/releases/tag/v0.1.0
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ This utility enables you to call `code .` instead, just as you would in a WSL se

### Requirements

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

### VS Code Server

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.1.1
20 changes: 15 additions & 5 deletions code_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

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

from pathlib import Path
import subprocess as sp
from typing import Iterable, List, Tuple
import time
import subprocess as sp
import os
from distutils.spawn import find_executable
from typing import Iterable, List, Tuple
from pathlib import Path

MAX_IDLE_TIME = 4 * 60 * 60

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

def check_for_binaries():
if find_executable('socat') is None:
fail(
'"socat" not found in $PATH, but is required for code-connect'
)

def main(shell: str = None, max_idle_time: int = MAX_IDLE_TIME):
check_for_binaries()

# Determine shell for outputting the proper format
if not shell:
shell = os.getenv('SHELL', 'bash')
Expand All @@ -62,9 +71,10 @@ def main(shell: str = None, max_idle_time: int = MAX_IDLE_TIME):

code_binary = code_repo / 'bin' / 'code'

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

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

0 comments on commit 1bfd067

Please sign in to comment.