-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfabfile.py
More file actions
executable file
·59 lines (50 loc) · 1.47 KB
/
fabfile.py
File metadata and controls
executable file
·59 lines (50 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
"""
Fabric fabfile for .homefiles.
"""
import fabric.api
import paramiko
import socket
# Run in a non-interactive mode, calling abort anytime it would
# normally prompt the user for input.
fabric.api.env.abort_on_prompts = True
# We must run the shell as a login shell (-l) so that install.py can
# find files in ~/bin/
fabric.api.env.shell = "/bin/sh -l -c"
DEPLOY_HOSTS = [
"crookshanks",
"deadeye",
"missy",
"molly",
"penguin",
"pepsi",
"shadow",
"tschutter@192.168.2.205"
]
def _is_host_up(host, port):
"""Determine if we can connect to host."""
# Set the timeout
original_timeout = socket.getdefaulttimeout()
new_timeout = 3
socket.setdefaulttimeout(new_timeout)
host_status = False
try:
paramiko.Transport((host, port))
host_status = True
except Exception:
print "[%s] WARNING: Cannot connect to port %s." % (host, port)
socket.setdefaulttimeout(original_timeout)
return host_status
# @fabric.api.parallel # broken?
@fabric.api.hosts(DEPLOY_HOSTS)
def deploy():
"""Deploy .homefiles updates to known hosts."""
if _is_host_up(fabric.api.env.host, int(fabric.api.env.port)):
with fabric.api.cd("~/.homefiles"):
# Update .homefiles
fabric.api.run("git pull")
# Install
fabric.api.run("python install.py")
with fabric.api.cd("~/.emacs.d"):
# Update .emacs.d
fabric.api.run("git pull")