Skip to content

Use requests instead of pyCurl#4

Merged
ymarcon merged 4 commits intomasterfrom
use-requests
Jun 18, 2025
Merged

Use requests instead of pyCurl#4
ymarcon merged 4 commits intomasterfrom
use-requests

Conversation

@kazoompa
Copy link
Copy Markdown
Member

No description provided.

@ymarcon ymarcon requested a review from Copilot June 17, 2025 20:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the Agate client from using PyCurl to Python’s requests library.

  • Replaces PyCurl calls with requests in client, request, and response handling.
  • Updates tests to include the new no_ssl_verify parameter and remove certificate validation in one test.
  • Adjusts dependency management and command-line arguments accordingly.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_restCall.py Updates authentication calls to pass no_ssl_verify and removes certificate usage.
pyproject.toml Removes the pycurl dependency and adds requests and urllib3 dependencies.
obiba_agate/rest.py Wraps REST command execution with a try/finally block to ensure client closure.
obiba_agate/core.py Replaces PyCurl usage with requests, updates header handling, and SSL verification.
obiba_agate/console.py Adds a new command-line argument to disable SSL certificate verification.

Comment thread obiba_agate/core.py Outdated

def content_type(self, value):
return self.header('Content-Type', value)
return self.headers.update({"Content-Type": value})
Copy link

Copilot AI Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content_type method currently returns the result of dict.update, which is None, breaking the method chaining pattern. Consider updating it to call self.header('Content-Type', value) or explicitly return self.

Suggested change
return self.headers.update({"Content-Type": value})
return self.header('Content-Type', value)

Copilot uses AI. Check for mistakes.
Comment thread obiba_agate/core.py Outdated
Comment on lines +380 to +381
[info["major"], info["minor"], info["patch"]] = self.version.split(".")
return info
Copy link

Copilot AI Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The direct destructuring assignment assumes the version string always splits into three parts. Consider adding validation or error handling to avoid potential issues with unexpected version formats.

Suggested change
[info["major"], info["minor"], info["patch"]] = self.version.split(".")
return info
version_parts = self.version.split(".")
if len(version_parts) == 3:
info["major"], info["minor"], info["patch"] = version_parts
return info
else:
# Handle malformed version string
return None

Copilot uses AI. Check for mistakes.
Comment thread obiba_agate/core.py Outdated
self.curl_option(pycurl.HTTPPOST, [("file1", (pycurl.FORM_FILE, filename))])
print("* File Content:")
print("[file=" + filename + ", size=" + str(os.path.getsize(filename)) + "]")
self.files = {"file": (filename, open(filename, "rb"))}
Copy link

Copilot AI Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file opened for upload is not explicitly closed after use. Consider using a context manager or ensuring the file is properly closed to avoid resource leaks.

Suggested change
self.files = {"file": (filename, open(filename, "rb"))}
with open(filename, "rb") as file:
self.files = {"file": (filename, file.read())}

Copilot uses AI. Check for mistakes.
@ymarcon ymarcon merged commit cb03020 into master Jun 18, 2025
6 checks passed
@ymarcon ymarcon deleted the use-requests branch June 18, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants