f6dd79baba82bf7d8c0fc47fd971aa8801620784
[treecutter.git] / treecutter / tools.py
1 #!/usr/bin/python
2 import os
3 import fnmatch
4 import subprocess
5 import amara
6 import re
7 import tempfile
8 import errno
9 import time
10 import argparse
11 import shutil
12 import pygraphviz as pgv
13 import glob
14 import gettext
15 import shutil
16 from amara import bindery
17 from amara.xslt import transform
18 from Cheetah.Template import Template
19
20 def mkdir_p(path):
21     try:
22         os.makedirs(path)
23     except OSError as exc: # Python >2.5
24         if exc.errno == errno.EEXIST:
25             pass
26         else: raise
27
28 def publish(src,target):
29     cmd = ["rsync","-a","--delete",src,target]
30     retcode = subprocess.call(cmd)
31     if retcode:
32         print 'Error: '+' '.join(cmd)+' Returncode ['+str(retcode)+']'
33
34 def ssh_cmd(target, command):
35     t = target.split(":")
36     c = command.split()
37     cmd = ["ssh",t[0],c[0],c[1],t[1]]
38     retcode = subprocess.call(cmd)
39     if retcode:
40         print 'Error: '+' '.join(cmd)+' Returncode ['+str(retcode)+']'