a_frame/utils/action_providers/GitAction.py
def execute_template(self, template):
        """
        We now have the global config (if any), the instance config, and the completed template from the input_form
        and can perform the desired request
        :param template: the completed template from the user or API
        :return Boolean based on execution outcome.
        """
        print "executing %s" % template

        local_directory = '/var/cache/aframe/' + self.repository_name

        if not os.path.exists(self.local_directory):
            os.makedirs(self.local_directory)

        try:
            repo = git.Repo(self.local_directory)

        except git.exc.InvalidGitRepositoryError:
            repo = git.Repo.init(self.local_directory, bare=False)

        if len(repo.remotes) == 0:
            # this shouldn't happen
            # but if we happen to get a local repo that's already been
            # defined but no remotes
            origin = repo.create_remote('origin', url=self.remote_url)
        else:
            origin = repo.remotes.origin

        try:
            origin.fetch()
        except git.exc.GitCommandError as gec:
            print gec
            return "Could not init remote git repo"

        try:
            # let's ensure we have the latest and greatest
            origin.pull()
            # in this case we don't actually need to set tracking or
            # to push configs back upstream
            if self.target_branch in origin.refs:
                repo.create_head(self.target_branch, origin.refs[self.target_branch])
                this_repo_head = repo.heads[self.target_branch]
                this_repo_head.set_tracking_branch(origin.refs[self.target_branch])
                this_repo_head.checkout()

            target_directory_path = self.local_directory + self.target_directory
            if not os.path.exists(target_directory_path):
                os.makedirs(target_directory_path)

            if not target_directory_path.endswith('/'):
                target_directory_path += '/'

            target_file_path = target_directory_path + self.target_filename

            with open(target_file_path, 'wb') as tfp:
                tfp.write(template)

            repo.git.add(A=True)
            repo.index.commit(self.commit_message)
            origin.push()

        except Exception as e:
            print str(e)
            return "Error committing to remote git repo"

        We now have the global config (if any), the instance config, and the completed template from the input_form
        and can perform the desired request
        :param template: the completed template from the user or API
        :return Boolean based on execution outcome.
        
We now have the global config (if any), the instance config, and the completed template from the input_form
and can perform the desired request
:param template: the completed template from the user or API
:return Boolean based on execution outcome.
We now have the global config ( if any ) the instance config and the completed template from the input_form and can perform the desired request : param template : the completed template from the user or API : return Boolean based on execution outcome .
def execute_template(self, template):
        print "executing %s" % template
        local_directory = '/var/cache/aframe/' + self.repository_name
        if not os.path.exists(self.local_directory):
            os.makedirs(self.local_directory)
        try:
            repo = git.Repo(self.local_directory)
        except git.exc.InvalidGitRepositoryError:
            repo = git.Repo.init(self.local_directory, bare=False)
        if len(repo.remotes) == 0:
            origin = repo.create_remote('origin', url=self.remote_url)
        else:
            origin = repo.remotes.origin
        try:
            origin.fetch()
        except git.exc.GitCommandError as gec:
            print gec
            return "Could not init remote git repo"
        try:
            origin.pull()
            if self.target_branch in origin.refs:
                repo.create_head(self.target_branch, origin.refs[self.target_branch])
                this_repo_head = repo.heads[self.target_branch]
                this_repo_head.set_tracking_branch(origin.refs[self.target_branch])
                this_repo_head.checkout()
            target_directory_path = self.local_directory + self.target_directory
            if not os.path.exists(target_directory_path):
                os.makedirs(target_directory_path)
            if not target_directory_path.endswith('/'):
                target_directory_path += '/'
            target_file_path = target_directory_path + self.target_filename
            with open(target_file_path, 'wb') as tfp:
                tfp.write(template)
            repo.git.add(A=True)
            repo.index.commit(self.commit_message)
            origin.push()
        except Exception as e:
            print str(e)
            return "Error committing to remote git repo"
def execute_template ( self , template ) : print "executing %s" % template local_directory = '/var/cache/aframe/' + self . repository_name if not os . path . exists ( self . local_directory ) : os . makedirs ( self . local_directory ) try : repo = git . Repo ( self . local_directory ) except git . exc . InvalidGitRepositoryError : repo = git . Repo . init ( self . local_directory , bare = False ) if len ( repo . remotes ) == 0 : origin = repo . create_remote ( 'origin' , url = self . remote_url ) else : origin = repo . remotes . origin try : origin . fetch ( ) except git . exc . GitCommandError as gec : print gec return "Could not init remote git repo" try : origin . pull ( ) if self . target_branch in origin . refs : repo . create_head ( self . target_branch , origin . refs [ self . target_branch ] ) this_repo_head = repo . heads [ self . target_branch ] this_repo_head . set_tracking_branch ( origin . refs [ self . target_branch ] ) this_repo_head . checkout ( ) target_directory_path = self . local_directory + self . target_directory if not os . path . exists ( target_directory_path ) : os . makedirs ( target_directory_path ) if not target_directory_path . endswith ( '/' ) : target_directory_path += '/' target_file_path = target_directory_path + self . target_filename with open ( target_file_path , 'wb' ) as tfp : tfp . write ( template ) repo . git . add ( A = True ) repo . index . commit ( self . commit_message ) origin . push ( ) except Exception as e : print str ( e ) return "Error committing to remote git repo"
We now have the global config (if any), the instance config, and the completed template from the input_form
and can perform the desired request
:param template: the completed template from the user or API
:return Boolean based on execution outcome.
We now have the global config ( if any ) the instance config and the completed template from the input_form and can perform the desired request : param template : the completed template from the user or API : return Boolean based on execution outcome .
"""
        We now have the global config (if any), the instance config, and the completed template from the input_form
        and can perform the desired request
        :param template: the completed template from the user or API
        :return Boolean based on execution outcome.
        """ # this shouldn't happen # but if we happen to get a local repo that's already been # defined but no remotes # let's ensure we have the latest and greatest # in this case we don't actually need to set tracking or # to push configs back upstream
self
template