Bug 1275409: move taskcluster_graph.from_now to taskgraph.util.time; r?wcosta
MozReview-Commit-ID: 3GFO4f34dg8
--- a/taskcluster/taskgraph/kind/docker_image.py
+++ b/taskcluster/taskgraph/kind/docker_image.py
@@ -13,17 +13,17 @@ import tarfile
import time
from . import base
from ..types import Task
from taskgraph.util.docker import docker_image
import taskcluster_graph.transform.routes as routes_transform
import taskcluster_graph.transform.treeherder as treeherder_transform
from taskgraph.util.templates import Templates
-from taskcluster_graph.from_now import (
+from taskgraph.util.time import (
json_time_from_now,
current_json_time,
)
logger = logging.getLogger(__name__)
GECKO = os.path.realpath(os.path.join(__file__, '..', '..', '..', '..'))
ARTIFACT_URL = 'https://queue.taskcluster.net/v1/task/{}/artifacts/{}'
INDEX_URL = 'https://index.taskcluster.net/v1/task/{}'
--- a/taskcluster/taskgraph/kind/legacy.py
+++ b/taskcluster/taskgraph/kind/legacy.py
@@ -23,17 +23,17 @@ from taskcluster_graph.mach_util import
configure_dependent_task,
set_interactive_task,
remove_caches_from_task,
query_vcs_info
)
import taskcluster_graph.transform.routes as routes_transform
import taskcluster_graph.transform.treeherder as treeherder_transform
from taskcluster_graph.commit_parser import parse_commit
-from taskcluster_graph.from_now import (
+from taskgraph.util.time import (
json_time_from_now,
current_json_time,
)
from taskgraph.util.templates import Templates
import taskcluster_graph.build_task
from taskgraph.util.docker import docker_image
# TASKID_PLACEHOLDER is the "internal" form of a taskid; it is substituted with
rename from testing/taskcluster/tests/test_from_now.py
rename to taskcluster/taskgraph/test/test_util_time.py
--- a/testing/taskcluster/tests/test_from_now.py
+++ b/taskcluster/taskgraph/test/test_util_time.py
@@ -1,12 +1,18 @@
+# -*- coding: utf-8 -*-
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
import unittest
import mozunit
from datetime import datetime
-from taskcluster_graph.from_now import (
+from taskgraph.util.time import (
InvalidString,
UnknownTimeMeasurement,
value_of,
json_time_from_now
)
class FromNowTest(unittest.TestCase):
rename from testing/taskcluster/taskcluster_graph/from_now.py
rename to taskcluster/taskgraph/util/time.py
--- a/testing/taskcluster/taskcluster_graph/from_now.py
+++ b/taskcluster/taskgraph/util/time.py
@@ -1,8 +1,12 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
# Python port of the ms.js node module this is not a direct port some things are
# more complicated or less precise and we lean on time delta here.
import re
import datetime
PATTERN=re.compile(
'((?:\d+)?\.?\d+) *([a-z]+)'
@@ -83,8 +87,9 @@ def json_time_from_now(input_str, now=No
return time.isoformat() + 'Z'
def current_json_time():
'''
:returns: JSON string representation of the current time.
'''
return datetime.datetime.utcnow().isoformat() + 'Z'
+