File tree 7 files changed +93
-0
lines changed
7 files changed +93
-0
lines changed Original file line number Diff line number Diff line change 91
91
92
92
# Rope project settings
93
93
.ropeproject
94
+ * /.pytest_cache /
95
+ .vscode
Original file line number Diff line number Diff line change
1
+ # fabric2-sample
2
+
3
+ use fabric v2 to execute shell commands remotely over SSH.
4
+
5
+ [ Tutorial] ( https://docs.fabfile.org/en/2.5/getting-started.html#addendum-the-fab-command-line-tool )
6
+
7
+ ## Running on host
8
+
9
+ ``` bash
10
+ # create virtual env
11
+ $ virtualenv venv -p python3 && source venv/bin/activate
12
+ $ pip install --upgrade pip && \
13
+ pip install -r requirements.txt && \
14
+ pip install -r requirements-dev.txt
15
+ ```
16
+
17
+ [ Command-line interface] ( https://docs.fabfile.org/en/2.5/cli.html )
18
+
19
+ ``` bash
20
+ # running command
21
+ $ fab --list
22
+ $ fab -H dev.gpu install-zsh
23
+ ```
24
+
25
+ [ Configuration] ( https://docs.fabfile.org/en/2.5/concepts/configuration.html ) ./fabric.yaml
26
+
27
+ ``` yaml
28
+ connect_kwargs :
29
+ password : welcome-to-heaven
30
+ sudo :
31
+ password : welcome-to-heaven
32
+ timeouts :
33
+ connect : 10
34
+ user : god
35
+ port : 22
36
+ ` ` `
Original file line number Diff line number Diff line change
1
+ from fabric import Connection , task
2
+
3
+
4
+ @task
5
+ def install_zsh (c ):
6
+ """install oh-my-zsh
7
+
8
+ c [context](http://docs.pyinvoke.org/en/latest/api/context.html)
9
+
10
+ https://github.com/ohmyzsh/ohmyzsh
11
+ """
12
+ c .run ("echo $SHELL" )
13
+ # http://docs.pyinvoke.org/en/latest/api/runners.html
14
+ if c .run ("test -d ~/.oh-my-zsh" , warn = True ).failed :
15
+ print ("install zsh" )
16
+ c .sudo ("apt install zsh -y" )
17
+ print ("install oh-my-zsh" )
18
+ # c.run('sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"')
19
+ c .put ("install.sh" , "/tmp/install.sh" )
20
+ c .run ("sh /tmp/install.sh" )
21
+ # c.sudo("chsh -s $(which zsh)", warn=True)
22
+ if c .run ("test -f ~/.zshrc" , warn = True ).ok :
23
+ print (f"install on { c .config ['user' ]} @{ c .host } " )
24
+
25
+ # c.run("source ~/.zshrc", shell="/bin/zsh", env={})
26
+ # c.run("omz theme use ys")
27
+ # c.run("omz update")
Original file line number Diff line number Diff line change
1
+ --index https://mirrors.aliyun.com/pypi/simple
2
+ black >= 20.8b1
3
+ isort >= 5.6.0
4
+ mypy == 0.790
5
+ pytest >= 6.1.0
Original file line number Diff line number Diff line change
1
+ --index https://mirrors.aliyun.com/pypi/simple
2
+ fabric == 2.5.0
3
+ python-dotenv >= 0.15.0
Original file line number Diff line number Diff line change
1
+ # https://docs.fabfile.org/en/2.5/concepts/configuration.html#ssh-config
2
+ Host *
3
+ ConnectTimeout 10
4
+ ForwardAgent no
5
+ ForwardX11 no
6
+ ForwardX11Trusted yes
7
+ User tx-deepocean
8
+ Port 22
9
+ Protocol 2
10
+ connect_kwargs tx-deepocean tuixiang2017
Original file line number Diff line number Diff line change
1
+ # https://docs.python.org/zh-cn/3/library/subprocess.html
2
+ import logging
3
+ import subprocess
4
+
5
+
6
+ def run (cmd , verbose = True ) -> None :
7
+ """Run Command, use stdout as output"""
8
+ if verbose :
9
+ logging .debug (cmd )
10
+ subprocess .run (args = cmd , shell = True , check = True )
You can’t perform that action at this time.
0 commit comments