fosslight-util 2.1.15__py3-none-any.whl → 2.1.17__py3-none-any.whl

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.
@@ -26,6 +26,7 @@ import platform
26
26
  import subprocess
27
27
  import re
28
28
  from typing import Tuple
29
+ import urllib.parse
29
30
 
30
31
  logger = logging.getLogger(constant.LOGGER_NAME)
31
32
  compression_extension = {".tar.bz2", ".tar.gz", ".tar.xz", ".tgz", ".tar", ".zip", ".jar", ".bz2"}
@@ -94,7 +95,8 @@ def parse_src_link(src_link):
94
95
 
95
96
  def cli_download_and_extract(link: str, target_dir: str, log_dir: str, checkout_to: str = "",
96
97
  compressed_only: bool = False, ssh_key: str = "",
97
- id: str = "", git_token: str = "") -> Tuple[bool, str, str, str]:
98
+ id: str = "", git_token: str = "",
99
+ called_cli: bool = True) -> Tuple[bool, str, str, str]:
98
100
  global logger
99
101
 
100
102
  success = True
@@ -126,7 +128,8 @@ def cli_download_and_extract(link: str, target_dir: str, log_dir: str, checkout_
126
128
  success_git, msg, oss_name, oss_version = download_git_clone(link, target_dir,
127
129
  checkout_to,
128
130
  tag, branch,
129
- ssh_key, id, git_token)
131
+ ssh_key, id, git_token,
132
+ called_cli)
130
133
  link = change_ssh_link_to_https(link)
131
134
  if (not is_rubygems) and (not success_git):
132
135
  if os.path.isfile(target_dir):
@@ -204,28 +207,44 @@ def get_github_token(git_url):
204
207
  return github_token
205
208
 
206
209
 
207
- def download_git_repository(refs_to_checkout, git_url, target_dir, tag):
210
+ def download_git_repository(refs_to_checkout, git_url, target_dir, tag, called_cli=True):
208
211
  success = False
209
212
  oss_version = ""
210
213
 
211
214
  logger.info(f"Download git url :{git_url}")
215
+ env = os.environ.copy()
216
+ if not called_cli:
217
+ env["GIT_TERMINAL_PROMPT"] = "0"
212
218
  if refs_to_checkout:
213
219
  try:
214
220
  # gitPython uses the branch argument the same whether you check out to a branch or a tag.
215
- Repo.clone_from(git_url, target_dir, branch=refs_to_checkout)
216
- success = True
217
- oss_version = refs_to_checkout
221
+ Repo.clone_from(git_url, target_dir, branch=refs_to_checkout, env=env)
222
+ if any(Path(target_dir).iterdir()):
223
+ success = True
224
+ oss_version = refs_to_checkout
225
+ logger.info(f"Files found in {target_dir} after clone.")
226
+ else:
227
+ logger.info(f"No files found in {target_dir} after clone.")
228
+ success = False
218
229
  except GitCommandError as error:
219
- logger.debug(f"Git checkout error:{error}")
230
+ logger.info(f"Git checkout error:{error}")
231
+ success = False
232
+ except Exception as e:
233
+ logger.info(f"Repo.clone_from error:{e}")
220
234
  success = False
221
235
 
222
236
  if not success:
223
- Repo.clone_from(git_url, target_dir)
224
- success = True
237
+ Repo.clone_from(git_url, target_dir, env=env)
238
+ if any(Path(target_dir).iterdir()):
239
+ success = True
240
+ else:
241
+ logger.info(f"No files found in {target_dir} after clone.")
242
+ success = False
225
243
  return success, oss_version
226
244
 
227
245
 
228
- def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch="", ssh_key="", id="", git_token=""):
246
+ def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch="",
247
+ ssh_key="", id="", git_token="", called_cli=True):
229
248
  oss_name = get_github_ossname(git_url)
230
249
  refs_to_checkout = decide_checkout(checkout_to, tag, branch)
231
250
  msg = ""
@@ -249,17 +268,19 @@ def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch="", s
249
268
  logger.info(f"Download git with ssh_key:{git_url}")
250
269
  git_ssh_cmd = f'ssh -i {ssh_key}'
251
270
  with Git().custom_environment(GIT_SSH_COMMAND=git_ssh_cmd):
252
- success, oss_version = download_git_repository(refs_to_checkout, git_url, target_dir, tag)
271
+ success, oss_version = download_git_repository(refs_to_checkout, git_url, target_dir, tag, called_cli)
253
272
  else:
254
273
  if id and git_token:
255
274
  try:
256
275
  m = re.match(r"^(ht|f)tp(s?)\:\/\/", git_url)
257
276
  protocol = m.group()
258
277
  if protocol:
259
- git_url = git_url.replace(protocol, f"{protocol}{id}:{git_token}@")
278
+ encoded_git_token = urllib.parse.quote(git_token, safe='')
279
+ encoded_id = urllib.parse.quote(id, safe='')
280
+ git_url = git_url.replace(protocol, f"{protocol}{encoded_id}:{encoded_git_token}@")
260
281
  except Exception as error:
261
282
  logger.info(f"Failed to insert id, token to git url:{error}")
262
- success, oss_version = download_git_repository(refs_to_checkout, git_url, target_dir, tag)
283
+ success, oss_version = download_git_repository(refs_to_checkout, git_url, target_dir, tag, called_cli)
263
284
 
264
285
  logger.info(f"git checkout: {oss_version}")
265
286
  refs_to_checkout = oss_version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight-util
3
- Version: 2.1.15
3
+ Version: 2.1.17
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Author: LG Electronics
@@ -4,7 +4,7 @@ fosslight_util/compare_yaml.py,sha256=eLqqCLgERxRHN5vsnpQVMXIEU862Lx66mD_y4uMgQE
4
4
  fosslight_util/constant.py,sha256=Ig3ACm9_QirE4389Wt-IfxOqRkVOUjqGnX1B05z2Byo,2151
5
5
  fosslight_util/correct.py,sha256=1WEAL-9_KhjFPLucPhv0PNN3K7avm0z8mU6sTuSyeHM,3864
6
6
  fosslight_util/cover.py,sha256=qqqKzxqFwKimal764FaugRUBcHWdeKt8af6xeK0mH8E,2040
7
- fosslight_util/download.py,sha256=5nLe0oE1pUHEawM4kLlryusPBlk6ptEvy4HtqwFmCMs,16292
7
+ fosslight_util/download.py,sha256=b55ZDso1nnAwIQwMyAYyxnJcvTYQx8eGVcIg9D1CpCc,17347
8
8
  fosslight_util/exclude.py,sha256=fDmBsZJ_F7O9Oh2T-07R03XNbElo1tFaf_z01KfSAqU,2399
9
9
  fosslight_util/help.py,sha256=Bmyz-eFP0X0qUfgFPrWiuyUPE0TLQfWjgfHTzJBIInc,2377
10
10
  fosslight_util/oss_item.py,sha256=8W2HlwqGH3l1iPPdvycrRYKsBSBpqAkqYyYtBVPgMtY,6868
@@ -24,9 +24,9 @@ fosslight_util/write_yaml.py,sha256=QlEKoIPQsEaYERfbP53TeKgnllYzhLQWm5wYjnWtVjE,
24
24
  fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
25
25
  fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
26
26
  fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
27
- fosslight_util-2.1.15.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
- fosslight_util-2.1.15.dist-info/METADATA,sha256=3tlh4jUQQ6TYuUb7lEhkVAtWf-CwZOQtDV3cj7EFxt0,6500
29
- fosslight_util-2.1.15.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
30
- fosslight_util-2.1.15.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
31
- fosslight_util-2.1.15.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
32
- fosslight_util-2.1.15.dist-info/RECORD,,
27
+ fosslight_util-2.1.17.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ fosslight_util-2.1.17.dist-info/METADATA,sha256=dG34Ulv95GV7bhARLITbYUWmEe52VqazekVCRfQ0vqs,6500
29
+ fosslight_util-2.1.17.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
30
+ fosslight_util-2.1.17.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
31
+ fosslight_util-2.1.17.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
32
+ fosslight_util-2.1.17.dist-info/RECORD,,