# 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

    def _make_symlink(self, cache_path, file_name, script):
        script_folder = os.path.join(self._cache_folder, script)
        if not os.path.isdir(script_folder):
            os.mkdir(script_folder)

        file_folder = os.path.join(script_folder,
                                   os.path.dirname(file_name))
        if not os.path.isdir(file_folder):
            os.makedirs(file_folder)

        if cache_path is not None:
            script_path = os.path.join(script_folder, file_name)
            if not os.path.lexists(script_path):
                os.symlink(cache_path, script_path)
            return script_path

    def _fetch_file(self, file_id):
        if file_id in self._fetched_files:
            return self._fetched_files[file_id]

        filedef = self._files[file_id]
        out_path = os.path.join(self._cache_folder, file_id)
        body_type = filedef.get('BodyType', 'Text')
        with open(out_path, 'w') as out_file:
            if body_type == 'Text':
                out_file.write(filedef['Body'])
            elif body_type == 'Base64':
                out_file.write(util.b64decode(filedef['Body']))


# 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


    def _make_symlink(self, cache_path, file_name, script):
        script_folder = os.path.join(self._cache_folder, script)
        if not os.path.isdir(script_folder):
            os.mkdir(script_folder)

        file_folder = os.path.join(script_folder,
                                   os.path.dirname(file_name))
        if not os.path.isdir(file_folder):
            os.makedirs(file_folder)

        if cache_path is not None:
            script_path = os.path.join(script_folder, file_name)
            if not os.path.lexists(script_path):
                os.symlink(cache_path, script_path)
            return script_path

    def _fetch_file(self, file_id):
        if file_id in self._fetched_files:
            return self._fetched_files[file_id]

        filedef = self._files[file_id]
        out_path = os.path.join(self._cache_folder, file_id)
        body_type = filedef.get('BodyType', 'Text')
        with open(out_path, 'w') as out_file:
            if body_type == 'Text':
                out_file.write(filedef['Body'])
            elif body_type == 'Base64':
                out_file.write(util.b64decode(filedef['Body']))


        self._fetched_files[file_id] = out_path