Merge pull request #19 from xonssh/0.2.9

Faster getting host info
This commit is contained in:
anki-code 2020-02-17 00:06:06 +03:00 committed by GitHub
commit 184bd0c0f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 58 deletions

View file

@ -91,7 +91,7 @@ xxh arguments:
The xxh xonsh will use pip and python from `xonsh.AppImage` by default. You can install pip packages ordinally with `pip install`. They will appear in `$XXH_HOME/pip`.
## How it works?
### How it works?
When you run `xxh <server>` command:
@ -104,13 +104,13 @@ When you run `xxh <server>` command:
## Development
Use [xxh-tests](https://github.com/xonssh/xxh-tests) environment for development and contribution.
## Known Issues
### Known Issues
### GLIBs versions
#### GLIBs versions
Current method to make xonsh portable is using an [AppImage](https://appimage.org/) which was built on [manylinux2010 (PEP 571)](https://github.com/niess/linuxdeploy-plugin-python/issues/12). In case you see the error like ``/xonsh-x86_64.AppImage: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.25 not found (required by /ppp/xonsh-x86_64.AppImage)`` this means you should rebuild the AppImage for older version of linux distributive. Try [linuxdeploy-plugin-python](https://github.com/niess/linuxdeploy-plugin-python/).
### WSL1: ^Z
#### WSL1: ^Z
```
# xxh YT-1300
@ -121,7 +121,7 @@ This issue was addressed to Xonsh team in [3367](https://github.com/xonsh/xonsh/
WSL2 is not tested yet.
### Related issues
#### Related issues
What will make xxh more universal and stable in the future:
* [AppImages run on Alpine](https://github.com/AppImage/AppImageKit/issues/1015)

View file

@ -1,29 +0,0 @@
**xxh plugin** — is the set of files which will be run when xonsh will be installed or started though xxh.
## xxh plugins list
[Search xxh plugins on Github](https://github.com/search?q=xxh-plugin&type=Repositories)
Pinned plugins:
* [Pipe Liner](https://github.com/xonssh/xxh-plugin-pipe-liner)
* [Bar Theme](https://github.com/xonssh/xxh-plugin-theme-bar)
* [Autojump](https://github.com/xonssh/xxh-plugin-autojump)
## Install xxh plugin
To install xxh plugin just place the plugin directory to the `plugins` in xxh home path. Example:
```
cd ~/.xxh/plugins/
git clone --depth 1 https://github.com/xonssh/xxh-plugin-theme-bar
```
Then run:
```
xxh <server>
```
## Create xxh plugin
To create xxh plugin you can create `your_plugin` directory in `~/.xxh/plugins/your_plugin` (by default) on your home host with files:
* `install.xsh` will be executed once after xxh installation on the host
* `xonshrc.xsh` will be executed every time you'll be connect via xxh to the host

View file

@ -16,9 +16,5 @@ echo xxh_home_realpath=$xxh_home_realpath
echo xxh_version=$xxh_version
echo xxh_home_writable=`[ -w $xxh_home_realpath ] && echo "1" ||echo "0"`
echo xxh_parent_home_writable=`[ -w $(dirname $xxh_home_realpath) ] && echo "1" ||echo "0"`
echo xxh_home_freespace=`[ -d $xxh_home_realpath ] && df -k --output=avail $xxh_home_realpath | tail -n1`
echo xxh_plugins_rc=`[ -d $xxh_plugins_path ] && find $xxh_plugins_path | grep xonshrc.xsh`
echo bash=`command -v bash`
echo rsync=`command -v rsync`
echo scp=`command -v scp`

View file

@ -1,7 +1,7 @@
import sys
global_settings = {
'XXH_VERSION': '0.2.8'
'XXH_VERSION': '0.2.9'
}
if __name__ == "__main__":

View file

@ -1,9 +0,0 @@
import os, glob
import_path = os.path.join($XXH_HOME, 'plugins')
xonshrc_plugins_rc=[]
for rc in sorted(glob.glob(os.path.join(import_path, '*/xonshrc.xsh'))):
xonshrc_plugins_rc.append(rc)
# Prefix `xxh-plugins: ` is needed to workaround some cases when ssh write warnings to stdout and return before this
print(f"xxh-plugins# {' '.join(xonshrc_plugins_rc)}")

22
xxh
View file

@ -246,7 +246,7 @@ if opt.install:
eprint(f'Method "{opt.method}" is not supported now')
if opt.install_force:
eprint(f'Before upload xxh remove host directory {host}:{host_xxh_home}')
eprint(f'Remove host xxh home {host}:{host_xxh_home}')
echo @(f"rm -rf {host_xxh_home}/*") | ssh @(ssh_v) @(ssh_arguments) @(host) -T "bash -s"
eprint(f"Install xxh to {host}:{host_xxh_home}" )
@ -269,16 +269,18 @@ if opt.install:
plugins_fullpath = os.path.join(local_xxh_home_path, 'plugins')
if os.path.exists(plugins_fullpath):
eprint(f'Run plugins post install on {host}')
scripts=''
for script in sorted(glob.glob(os.path.join(plugins_fullpath, os.path.join('*','post_install.xsh')), recursive=True)):
scripts += " && %s -i --rc %s -- %s" % (host_xonsh_bin, host_xonshrc, script.replace(local_xxh_home_path + os.sep, ''))
eprint(f' * {script}')
plugin_post_installs = sorted(glob.glob(os.path.join(plugins_fullpath, os.path.join('*', 'post_install.xsh')), recursive=True))
if len(plugin_post_installs) > 0:
eprint(f'Run plugins post install on {host}')
scripts=''
for script in plugin_post_installs:
scripts += " && %s -i --rc %s -- %s" % (host_xonsh_bin, host_xonshrc, script.replace(local_xxh_home_path + os.sep, ''))
eprint(f' * {script}')
if scripts:
echo @(f"cd {host_xxh_home} {scripts}" ) | ssh @(ssh_v) @(ssh_arguments) @(host) -T "bash -s" 1>&2
if scripts:
echo @(f"cd {host_xxh_home} {scripts}" ) | ssh @(ssh_v) @(ssh_arguments) @(host) -T "bash -s" 1>&2
eprint('Check xonsh')
eprint(f'Check {opt.method}')
host_settings_file = os.path.join(host_xxh_home, 'settings.py')
check = $(ssh @(ssh_v) @(ssh_arguments) @(host) -t @(host_xonsh_bin) --no-script-cache -i --rc @(host_xonshrc) -- @(host_settings_file) )
@ -286,7 +288,7 @@ if opt.install:
eprint(f'Check xonsh result:\n{check}')
if check == '' or 'AppImages require FUSE to run' in check:
eprint('Check failed. Unpack AppImage...')
eprint('AppImage is not supported by host. Trying to unpack and run...')
host_xonsh_bin_new = os.path.join(host_xxh_home, 'xonsh-squashfs/usr/python/bin/xonsh')
ssh @(ssh_v) @(ssh_arguments) @(host) -t @(f"cd {host_xxh_home} && ./{xonsh_bin_name} --appimage-extract | grep -E 'usr/python/bin/xonsh$' && mv squashfs-root xonsh-squashfs && mv {host_xonsh_bin} {host_xonsh_bin}-disabled && ln -s {host_xonsh_bin_new}") 1>&2
host_xonsh_bin = host_xonsh_bin_new