2011-10-11 13:25:29 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
|
|
|
|
#
|
|
|
|
# This file is part of cdist.
|
|
|
|
#
|
|
|
|
# cdist is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# cdist is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2011-10-11 13:50:50 +00:00
|
|
|
import io
|
2011-10-11 13:25:29 +00:00
|
|
|
import logging
|
2011-10-11 15:05:35 +00:00
|
|
|
import os
|
2011-10-11 13:50:50 +00:00
|
|
|
#import stat
|
|
|
|
#import shutil
|
|
|
|
#import sys
|
|
|
|
#import tempfile
|
|
|
|
#import time
|
|
|
|
#
|
|
|
|
#import cdist.exec
|
2011-10-11 13:25:29 +00:00
|
|
|
|
2011-10-11 15:05:35 +00:00
|
|
|
import cdist
|
|
|
|
|
2011-10-11 13:25:29 +00:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2011-10-12 15:36:00 +00:00
|
|
|
class GlobalExplorer(object):
|
2011-10-12 15:27:21 +00:00
|
|
|
def __init__(self, local_path, remote_path):
|
|
|
|
self.local_path = local_path
|
|
|
|
self.remote_path = remote_path
|
2011-10-12 14:59:02 +00:00
|
|
|
|
2011-10-12 15:27:21 +00:00
|
|
|
def run(self):
|
2011-10-12 14:59:02 +00:00
|
|
|
"""Run global explorers"""
|
|
|
|
log.info("Running global explorers")
|
|
|
|
|
|
|
|
outputs = {}
|
|
|
|
for explorer in os.listdir(src_path):
|
|
|
|
outputs[explorer] = io.StringIO()
|
|
|
|
cmd = []
|
|
|
|
cmd.append("__explorer=" + remote_dst_path)
|
|
|
|
cmd.append(os.path.join(remote_dst_path, explorer))
|
|
|
|
cdist.exec.run_or_fail(cmd, stdout=outputs[explorer], remote_prefix=True)
|
|
|
|
|
2011-10-12 15:27:21 +00:00
|
|
|
def transfer(self):
|
2011-10-11 13:25:29 +00:00
|
|
|
"""Transfer the global explorers"""
|
|
|
|
self.remote_mkdir(self.remote_global_explorer_path)
|
|
|
|
self.transfer_path(self.global_explorer_path,
|
|
|
|
self.remote_global_explorer_path)
|