# Path: muranoagent/common/config.py
# CONF = cfg.CONF
# def parse_args(args=None, usage=None, default_config_files=None):
# 
# Path: muranoagent/util.py
# def _to_bytes(string):
# def b64encode(string):
# def b64decode(string):


import git
import os
import re
import requests
import shutil
import subprocess
import urllib
from oslo_log import log as logging
from oslo_utils import encodeutils
from muranoagent.common import config
from muranoagent import util
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.




CONF = config.CONF
LOG = logging.getLogger(__name__)


class FilesManager(object):
    def __init__(self, execution_plan):
        self._fetched_files = {}
        self._files = execution_plan.get('Files') or {}

        self._cache_folder = os.path.join(
            CONF.storage, 'files', execution_plan.ID)
        if os.path.exists(self._cache_folder):
            self.clear()
        os.makedirs(self._cache_folder, 0o700)

    def put_file(self, file_id, script):
        if type(file_id) is dict:
            file_name = list(file_id.keys())[0]
            file_def = file_id[file_name]
        else:
            file_def = self._files[file_id]
            file_name = file_def['Name']


# Path: muranoagent/common/config.py
# CONF = cfg.CONF
# def parse_args(args=None, usage=None, default_config_files=None):
# 
# Path: muranoagent/util.py
# def _to_bytes(string):
# def b64encode(string):
# def b64decode(string):


# Path: muranoagent/files_manager.py
import git
import os
import re
import requests
import shutil
import subprocess
import urllib
from oslo_log import log as logging
from oslo_utils import encodeutils
from muranoagent.common import config
from muranoagent import util

# implied.
# See the License for the specific language governing permissions and
# limitations under the License.




CONF = config.CONF
LOG = logging.getLogger(__name__)


class FilesManager(object):
    def __init__(self, execution_plan):
        self._fetched_files = {}
        self._files = execution_plan.get('Files') or {}

        self._cache_folder = os.path.join(
            CONF.storage, 'files', execution_plan.ID)
        if os.path.exists(self._cache_folder):
            self.clear()
        os.makedirs(self._cache_folder, 0o700)

    def put_file(self, file_id, script):
        if type(file_id) is dict:
            file_name = list(file_id.keys())[0]
            file_def = file_id[file_name]
        else:
            file_def = self._files[file_id]
            file_name = file_def['Name']


        if file_def.get('Type') == 'Downloadable':