# Path: servi/command.py
# class Command(object):
#     def __init__(self):
#         self.special = {
#             "skip_init": False,
#             "parse_known_args": False
#         }
# 
#     def register_command_line(self, sub_parser):
#         pass
# 
#     def run(self, args, extra_args):
#         pass
# 
# Path: servi/utils.py
# def pathfor(fname, source):
#     if source is c.MASTER and fname == c.SERVIFILE_GLOBAL:
#         return c.SERVIFILE_GLOBAL_FULL
#     else:
#         return c.pathfor(fname, source, c.TEMPLATE, c.MASTER, c.TMPL_DIR_SITE,
#                          c.MASTER_DIR)
# 
# @contextmanager
# def reset_cwd():
#     origdir = os.getcwd()
#     yield
#     os.chdir(origdir)
# 
# Path: servi/exceptions.py
# class ServiError(Exception):
#     # Expected errrors. Handle gracefully (ie: no stack dump)
#     def __init__(self, msg=None):
#         self.msg = msg
# 
#     def __str__(self):
#         return (
#             '\n***** ERROR *****\n'
#             '{0}\n'
#             '\n**Servi Aborting**'.format(self.msg))


import subprocess
import os
import servi.config as c
from logging import info
from pprint import pformat
from servi.command import Command
from servi.utils import pathfor, reset_cwd
from servi.exceptions import ServiError



def addslash(text):
    # Adds a trailing slash for rsync to use source dir contents
    retval = text if text[-1] == '/' else text+'/'
    return retval



# Path: servi/command.py
# class Command(object):
#     def __init__(self):
#         self.special = {
#             "skip_init": False,
#             "parse_known_args": False
#         }
# 
#     def register_command_line(self, sub_parser):
#         pass
# 
#     def run(self, args, extra_args):
#         pass
# 
# Path: servi/utils.py
# def pathfor(fname, source):
#     if source is c.MASTER and fname == c.SERVIFILE_GLOBAL:
#         return c.SERVIFILE_GLOBAL_FULL
#     else:
#         return c.pathfor(fname, source, c.TEMPLATE, c.MASTER, c.TMPL_DIR_SITE,
#                          c.MASTER_DIR)
# 
# @contextmanager
# def reset_cwd():
#     origdir = os.getcwd()
#     yield
#     os.chdir(origdir)
# 
# Path: servi/exceptions.py
# class ServiError(Exception):
#     # Expected errrors. Handle gracefully (ie: no stack dump)
#     def __init__(self, msg=None):
#         self.msg = msg
# 
#     def __str__(self):
#         return (
#             '\n***** ERROR *****\n'
#             '{0}\n'
#             '\n**Servi Aborting**'.format(self.msg))


# Path: servi/commands/pushto.py
import subprocess
import os
import servi.config as c
from logging import info
from pprint import pformat
from servi.command import Command
from servi.utils import pathfor, reset_cwd
from servi.exceptions import ServiError




def addslash(text):
    # Adds a trailing slash for rsync to use source dir contents
    retval = text if text[-1] == '/' else text+'/'
    return retval



class PushtoCommand(Command):