libmozdata 0.2.0__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. {libmozdata-0.2.0/libmozdata.egg-info → libmozdata-0.2.3}/PKG-INFO +1 -1
  2. libmozdata-0.2.3/VERSION +1 -0
  3. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/bugzilla.py +9 -0
  4. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/fx_trains.py +27 -1
  5. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/lando.py +15 -3
  6. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/phabricator.py +8 -9
  7. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/release_owners.py +4 -2
  8. {libmozdata-0.2.0 → libmozdata-0.2.3/libmozdata.egg-info}/PKG-INFO +1 -1
  9. libmozdata-0.2.0/VERSION +0 -1
  10. {libmozdata-0.2.0 → libmozdata-0.2.3}/MANIFEST.in +0 -0
  11. {libmozdata-0.2.0 → libmozdata-0.2.3}/README.md +0 -0
  12. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/BZInfo.py +0 -0
  13. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/FXRevision.py +0 -0
  14. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/FileStats.py +0 -0
  15. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/HGFileInfo.py +0 -0
  16. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/__init__.py +0 -0
  17. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/buildhub.py +0 -0
  18. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/config.py +0 -0
  19. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/connection.py +0 -0
  20. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/handler.py +0 -0
  21. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/hgmozilla.py +0 -0
  22. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/modules.json +0 -0
  23. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/modules.py +0 -0
  24. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/patchanalysis.py +0 -0
  25. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/redash.py +0 -0
  26. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/socorro.py +0 -0
  27. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/utils.py +0 -0
  28. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/vcs_map.py +0 -0
  29. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/versions.py +0 -0
  30. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata/wiki_parser.py +0 -0
  31. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata.egg-info/SOURCES.txt +0 -0
  32. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata.egg-info/dependency_links.txt +0 -0
  33. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata.egg-info/not-zip-safe +0 -0
  34. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata.egg-info/requires.txt +0 -0
  35. {libmozdata-0.2.0 → libmozdata-0.2.3}/libmozdata.egg-info/top_level.txt +0 -0
  36. {libmozdata-0.2.0 → libmozdata-0.2.3}/requirements.txt +0 -0
  37. {libmozdata-0.2.0 → libmozdata-0.2.3}/setup.cfg +0 -0
  38. {libmozdata-0.2.0 → libmozdata-0.2.3}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: libmozdata
3
- Version: 0.2.0
3
+ Version: 0.2.3
4
4
  Summary: Library to access and aggregate several Mozilla data sources.
5
5
  Home-page: https://github.com/mozilla/libmozdata
6
6
  Author: Mozilla Release Management
@@ -0,0 +1 @@
1
+ 0.2.3
@@ -7,6 +7,7 @@ import re
7
7
 
8
8
  import requests
9
9
  import six
10
+ from requests import HTTPError
10
11
 
11
12
  import libmozdata.versions
12
13
 
@@ -1057,6 +1058,14 @@ class BugzillaShorten(Connection):
1057
1058
  if not self.url_handler.isactive():
1058
1059
  return
1059
1060
 
1061
+ if not isinstance(res, dict):
1062
+ # This is a workaround to handle cases where Bugzilla returns 200
1063
+ # response with HTML content instead of 4xx error.
1064
+ # See https://github.com/mozilla/libmozdata/issues/227
1065
+ if self.RAISE_ERROR:
1066
+ raise HTTPError("The response is not a valid JSON")
1067
+ return
1068
+
1060
1069
  self.url_handler.handle(res["url"])
1061
1070
 
1062
1071
 
@@ -14,10 +14,36 @@ class FirefoxTrains:
14
14
  URL = "https://whattrainisitnow.com/api/"
15
15
  TIMEOUT = 30
16
16
 
17
+ _instance = None
18
+
19
+ def __init__(self, cache: bool = True) -> None:
20
+ """Constructor
21
+
22
+ Args:
23
+ cache: If True, the API responses will be cached.
24
+ """
25
+
26
+ self._cache = {} if cache else None
27
+
28
+ @classmethod
29
+ def get_instance(cls):
30
+ """Get the singleton instance of FirefoxTrains."""
31
+ if cls._instance is None:
32
+ cls._instance = cls()
33
+ return cls._instance
34
+
17
35
  def __get(self, path):
36
+ if self._cache is not None and path in self._cache:
37
+ return self._cache[path]
38
+
18
39
  resp = requests.get(self.URL + path, timeout=self.TIMEOUT)
19
40
  resp.raise_for_status()
20
- return resp.json()
41
+ resp_json = resp.json()
42
+
43
+ if self._cache is not None:
44
+ self._cache[path] = resp_json
45
+
46
+ return resp_json
21
47
 
22
48
  def get_release_schedule(self, channel):
23
49
  """Get the release schedule for a given channel.
@@ -5,6 +5,8 @@
5
5
 
6
6
  import requests
7
7
 
8
+ from . import config
9
+
8
10
 
9
11
  class LandoWarnings(object):
10
12
  """
@@ -14,6 +16,7 @@ class LandoWarnings(object):
14
16
  def __init__(self, api_url, api_key):
15
17
  self.api_url = f"{api_url}/diff_warnings"
16
18
  self.api_key = api_key
19
+ self.USER_AGENT = config.get("User-Agent", "name", "libmozdata")
17
20
 
18
21
  def del_warnings(self, warnings):
19
22
  """
@@ -24,7 +27,10 @@ class LandoWarnings(object):
24
27
 
25
28
  response = requests.delete(
26
29
  f"{self.api_url}/{warning_id}",
27
- headers={"X-Phabricator-API-Key": self.api_key},
30
+ headers={
31
+ "X-Phabricator-API-Key": self.api_key,
32
+ "User-Agent": self.USER_AGENT,
33
+ },
28
34
  )
29
35
 
30
36
  if response.status_code != 200:
@@ -42,7 +48,10 @@ class LandoWarnings(object):
42
48
  "group": "LINT",
43
49
  "data": {"message": warning},
44
50
  },
45
- headers={"X-Phabricator-API-Key": self.api_key},
51
+ headers={
52
+ "X-Phabricator-API-Key": self.api_key,
53
+ "User-Agent": self.USER_AGENT,
54
+ },
46
55
  )
47
56
  if response.status_code != 201:
48
57
  raise Exception(
@@ -60,7 +69,10 @@ class LandoWarnings(object):
60
69
  "diff_id": diff_id,
61
70
  "group": "LINT",
62
71
  },
63
- headers={"X-Phabricator-API-Key": self.api_key},
72
+ headers={
73
+ "X-Phabricator-API-Key": self.api_key,
74
+ "User-Agent": self.USER_AGENT,
75
+ },
64
76
  )
65
77
  if response.status_code != 200:
66
78
  raise Exception(
@@ -5,7 +5,6 @@
5
5
 
6
6
  import collections
7
7
  import enum
8
- import functools
9
8
  import json
10
9
  import logging
11
10
  from urllib.parse import urlencode, urlparse
@@ -13,6 +12,8 @@ from urllib.parse import urlencode, urlparse
13
12
  import hglib
14
13
  import requests
15
14
 
15
+ from . import config
16
+
16
17
  HGMO_JSON_REV_URL_TEMPLATE = "https://hg.mozilla.org/mozilla-central/json-rev/{}"
17
18
  MOZILLA_PHABRICATOR_PROD = "https://phabricator.services.mozilla.com/api/"
18
19
 
@@ -44,14 +45,6 @@ class ArtifactType(enum.Enum):
44
45
  Uri = "uri"
45
46
 
46
47
 
47
- @functools.lru_cache(maxsize=2048)
48
- def revision_exists_on_central(revision):
49
- url = HGMO_JSON_REV_URL_TEMPLATE.format(revision)
50
- resp = requests.get(url)
51
- resp.raise_for_status()
52
- return resp.ok
53
-
54
-
55
48
  def revision_available(repo, revision):
56
49
  """
57
50
  Check if a revision is available on a Mercurial repo
@@ -215,6 +208,7 @@ class PhabricatorAPI(object):
215
208
  """
216
209
 
217
210
  def __init__(self, api_key, url=MOZILLA_PHABRICATOR_PROD):
211
+ self.USER_AGENT = config.get("User-Agent", "name", "libmozdata")
218
212
  self.api_key = api_key
219
213
  self.url = url
220
214
  assert self.url.endswith("/api/"), "Phabricator API must end with /api/"
@@ -228,6 +222,10 @@ class PhabricatorAPI(object):
228
222
  parts = urlparse(self.url)
229
223
  return parts.netloc
230
224
 
225
+ def get_header(self):
226
+ """Get the header to use each query"""
227
+ return {"User-Agent": self.USER_AGENT}
228
+
231
229
  def search_diffs(
232
230
  self,
233
231
  diff_phid=None,
@@ -662,6 +660,7 @@ class PhabricatorAPI(object):
662
660
  # Run POST request on api
663
661
  response = requests.post(
664
662
  self.url + path,
663
+ headers=self.get_header(),
665
664
  data=urlencode({"params": json.dumps(payload), "output": "json"}),
666
665
  )
667
666
  response.raise_for_status()
@@ -48,6 +48,7 @@ def get_owners():
48
48
  "Secondary",
49
49
  "Engineering REO",
50
50
  "Release Duty",
51
+ "QA Owner",
51
52
  "Corresponding ESR",
52
53
  "Release Date",
53
54
  ] != table[0]:
@@ -57,7 +58,7 @@ def get_owners():
57
58
  for row in table[1:]:
58
59
  try:
59
60
  # sometimes the date is 2019-XX-XX (when the date is not known)
60
- release_date = utils.get_date_ymd(row[6])
61
+ release_date = utils.get_date_ymd(row[7])
61
62
  except (AssertionError, ValueError):
62
63
  continue
63
64
 
@@ -68,7 +69,8 @@ def get_owners():
68
69
  "secondary": row[2],
69
70
  "engineering reo": row[3],
70
71
  "release duty": _get_list_people(row[4]),
71
- "corresponding esr": row[5],
72
+ "qa owner": row[5],
73
+ "corresponding esr": row[6],
72
74
  "release date": release_date,
73
75
  }
74
76
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: libmozdata
3
- Version: 0.2.0
3
+ Version: 0.2.3
4
4
  Summary: Library to access and aggregate several Mozilla data sources.
5
5
  Home-page: https://github.com/mozilla/libmozdata
6
6
  Author: Mozilla Release Management
libmozdata-0.2.0/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.0
File without changes
File without changes
File without changes
File without changes
File without changes