You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/02/07 10:37:20 UTC
[04/14] stratos git commit: Refactoring GitRepository class and
removing gittle and gitpython references from it
Refactoring GitRepository class and removing gittle and gitpython references from it
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/8baee1dc
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/8baee1dc
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/8baee1dc
Branch: refs/heads/master
Commit: 8baee1dc6d6054197d4c210b32fee2a10014c34f
Parents: e7219bb
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Jan 28 11:39:00 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Feb 7 15:07:07 2015 +0530
----------------------------------------------------------------------
.../modules/artifactmgt/git/agentgithandler.py | 39 +++++++++++++---
.../modules/artifactmgt/git/gitrepository.py | 48 --------------------
.../modules/artifactmgt/repository.py | 38 ++++++++++++++++
.../artifactmgt/repositoryinformation.py | 37 ---------------
.../extensions/defaultextensionhandler.py | 6 +--
.../modules/util/asyncscheduledtask.py | 1 +
6 files changed, 74 insertions(+), 95 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/8baee1dc/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/git/agentgithandler.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/git/agentgithandler.py b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/git/agentgithandler.py
index 4ae69eb..72be650 100644
--- a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/git/agentgithandler.py
+++ b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/git/agentgithandler.py
@@ -25,10 +25,9 @@ import subprocess
from ... util.log import LogFactory
from ... util import cartridgeagentutils, extensionutils, cartridgeagentconstants
-from gitrepository import GitRepository
from ... config import cartridgeagentconfiguration
from ... util.asyncscheduledtask import AbstractAsyncScheduledTask, ScheduledExecutor
-from ... artifactmgt.repositoryinformation import RepositoryInformation
+from ... artifactmgt.repository import Repository
class AgentGitHandler:
@@ -60,7 +59,7 @@ class AgentGitHandler:
they will be added to a git repository, the remote url added as origin, and then
a pull operation will be performed.
- :param RepositoryInformation repo_info: The repository information object
+ :param Repository repo_info: The repository information object
:return: A tuple containing whether it was an initial clone or not, and the repository
context object
:rtype: tuple(bool, GitRepository)
@@ -206,7 +205,7 @@ class AgentGitHandler:
# invalid configuration, need to delete and reclone
AgentGitHandler.log.warn("Git pull unsuccessful for tenant %r, invalid configuration. %r" % (repo_context.tenant_id, p))
cartridgeagentutils.delete_folder_tree(repo_context.local_repo_path)
- AgentGitHandler.clone(RepositoryInformation(
+ AgentGitHandler.clone(Repository(
repo_context.repo_url,
repo_context.repo_username,
repo_context.repo_password,
@@ -441,8 +440,8 @@ class AgentGitHandler:
# result = push_op.expect([commit_hash + " master -> master", "Authentication failed for"])
# if result != 0:
# raise Exception
- #TODO: handle push failure scenarios
- #push_op.interact()
+ # TODO: handle push failure scenarios
+ # push_op.interact()
push_op.expect(pexpect.EOF)
AgentGitHandler.log.debug("Pushed artifacts for tenant : " + tenant_id)
@@ -572,4 +571,30 @@ class ArtifactUpdateTask(AbstractAsyncScheduledTask):
if self.auto_commit:
self.log.debug("Running commit job")
- AgentGitHandler.commit_and_push(self.repo_info)
\ No newline at end of file
+ AgentGitHandler.commit_and_push(self.repo_info)
+
+
+class GitRepository:
+ """
+ Represents a git repository inside a particular instance
+ """
+
+ def __init__(self):
+ self.repo_url = None
+ """ :type : str """
+ self.local_repo_path = None
+ """ :type : str """
+ self.cloned = False
+ """ :type : bool """
+ self.tenant_id = None
+ """ :type : int """
+ self.repo_username = None
+ """ :type : str """
+ self.repo_password = None
+ """ :type : str """
+ self.is_multitenant = False
+ """ :type : bool """
+ self.commit_enabled = False
+ """ :type : bool """
+ self.scheduled_update_task = None
+ """:type : ScheduledExecutor """
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/8baee1dc/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/git/gitrepository.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/git/gitrepository.py b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/git/gitrepository.py
deleted file mode 100644
index d710d9b..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/git/gitrepository.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
-class GitRepository:
- """
- Represents a git repository inside a particular instance
- """
-
- def __init__(self):
- self.repo_url = None
- """ :type : str """
- self.local_repo_path = None
- """ :type : str """
- self.cloned = False
- """ :type : bool """
- self.repo = None
- """ :type : git.repo.base.Repo """
- self.gittle_repo = None
- """ :type : gittle.gittle.Gittle """
- self.tenant_id = None
- """ :type : int """
- self.key_based_auth = False
- """ :type : bool """
- self.repo_username = None
- """ :type : str """
- self.repo_password = None
- """ :type : str """
- self.is_multitenant = False
- """ :type : bool """
- self.commit_enabled = False
- """ :type : bool """
- self.scheduled_update_task = None
- """:type : ScheduledExecutor """
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/8baee1dc/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/repository.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/repository.py b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/repository.py
new file mode 100644
index 0000000..f2842b6
--- /dev/null
+++ b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/repository.py
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+class Repository:
+ """
+ Holds repository information to be used in artifact management
+ """
+
+ def __init__(self, repo_url, repo_username, repo_password, repo_path, tenant_id, is_multitenant, commit_enabled):
+ self.repo_url = repo_url
+ """ :type : str """
+ self.repo_username = repo_username
+ """ :type : str """
+ self.repo_password = repo_password
+ """ :type : str """
+ self.repo_path = repo_path
+ """ :type : str """
+ self.tenant_id = tenant_id
+ """ :type : int """
+ self.is_multitenant = is_multitenant
+ """ :type : bool """
+ self.commit_enabled = commit_enabled
+ """ :type : bool """
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/8baee1dc/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/repositoryinformation.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/repositoryinformation.py b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/repositoryinformation.py
deleted file mode 100644
index b67eada..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/artifactmgt/repositoryinformation.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-class RepositoryInformation:
- """
- Holds repository information to be used in artifact management
- """
-
- def __init__(self, repo_url, repo_username, repo_password, repo_path, tenant_id, is_multitenant, commit_enabled):
- self.repo_url = repo_url
- """ :type : str """
- self.repo_username = repo_username
- """ :type : str """
- self.repo_password = repo_password
- """ :type : str """
- self.repo_path = repo_path
- """ :type : str """
- self.tenant_id = tenant_id
- """ :type : int """
- self.is_multitenant = is_multitenant
- """ :type : bool """
- self.commit_enabled = commit_enabled
- """ :type : bool """
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/8baee1dc/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/extensions/defaultextensionhandler.py b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/extensions/defaultextensionhandler.py
index feb067c..3e73a60 100644
--- a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/extensions/defaultextensionhandler.py
+++ b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/extensions/defaultextensionhandler.py
@@ -67,8 +67,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
self.log.info("Executing git checkout")
# create repo object
- repo_info = RepositoryInformation(repo_url, repo_username, repo_password, local_repo_path, tenant_id,
- is_multitenant, commit_enabled)
+ repo_info = Repository(repo_url, repo_username, repo_password, local_repo_path, tenant_id,
+ is_multitenant, commit_enabled)
# checkout code
subscribe_run, repo_context = agentgithandler.AgentGitHandler.checkout(repo_info)
@@ -338,7 +338,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
return tenant.tenant_domain
from ..artifactmgt.git import agentgithandler
-from ..artifactmgt.repositoryinformation import RepositoryInformation
+from ..artifactmgt.repository import Repository
from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
from ..publisher import cartridgeagentpublisher
from ..exception.parameternotfoundexception import ParameterNotFoundException
http://git-wip-us.apache.org/repos/asf/stratos/blob/8baee1dc/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/util/asyncscheduledtask.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/util/asyncscheduledtask.py b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/util/asyncscheduledtask.py
index 4ff0416..d470d6e 100644
--- a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/util/asyncscheduledtask.py
+++ b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/util/asyncscheduledtask.py
@@ -18,6 +18,7 @@
import time
from threading import Thread
+
class AbstractAsyncScheduledTask:
"""
Exposes the contract to follow to implement a scheduled task to be executed by the ScheduledExecutor