Is chardetect.exe required for get request and content? - python-requests

is "chardetect.exe" executable required for a get request and content? Just wanted to know. If not needed, then is it okay to delete it so that I can store the chardet files in bitbucket/git without an executable?
Code to use:
req = requests.get(url)
with io.BytesIO() as buf:
buf.write(req.content)
buf.seek(0)

Requests currently requires the chardet package but doesn't rely on any of the CLI tools.
https://github.com/psf/requests/issues/5548#issuecomment-668228215

Related

How to test if url accepting query parameters using pytest-djnago

My django webserver url accept query-parameters. For ex. "mydomain.com?emp_name=abc&dept=admin".
I want to automate this write a test using pytest-djnago to see if the url accepts the query parameters or not. Please suggest.
There are two ways to achive this.
My setup :
Django 3.2.12
django-test-curl 0.2.0
gunicorn 20.1.0
pytest 7.0.1
pytest-django 4.5.2
1) By using pytest-curl-report plugin (https://pypi.org/project/pytest-curl-report/)
I was getting below error after installing the "pytest-curl-report 0.5.4" plugin.
Error:
`pluggy._manager.PluginValidationError: Plugin 'curl-report' for hook
'pytest_runtest_makereport'
hookimpl definition: pytest_runtest_makereport(multicall, item, call)
Argument(s) {'multicall'} are declared in the hookimpl but can not be found in the hookspec`
I tired multiple install/unistall but it didnt helped.
Also I didnt found any fix this issue on google, so I skipped this one and decided to use django-test-curl plugin. See point no. 2)
2) By using django-test-curl plugin ("https://github.com/crccheck/django-test-curl")
$ pip3 install django-test-curl
Usage
from django_test_curl import CurlClient
class SimpleTest(TestCase):
def setUp(self):
self.client = CurlClient()
def test_details(self):
response = self.client.curl("""
curl http://localhost:8000/customer/details/
""")
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context['customers']), 5)

Swift: How to decode Base64Url into json object like JWT

I have the following JWT encode payload:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJUaXRsZSI6Ik5pY2UiLCJuYW1lIjoiSmltbXkiLCJhZ2UiOjU1fQ.DSdqRFRPM4Hep704s3cvWkpH5FFpnIc82uVUswHbaz4
But I haven't found a way to decode this string like JWT does.
By any chance any of you knows a way in swift to decode this payload?
I'll really appreciate your help.
Add dependencies
Add the Swift-JWT package to the dependencies within your application’s Package.swift file. Substitute "x.x.x" with the latest Swift-JWT release.
.package(url: "https://github.com/IBM-Swift/Swift-JWT.git", from: "x.x.x")
Add SwiftJWT to your target's dependencies:
.target(name: "example", dependencies: ["SwiftJWT"]),
Import package
import SwiftJWT
Cocoapods
To include Swift-JWT in a project using CocoaPods, add SwiftJWT to your Podfile:
pod 'SwiftJWT'
Try this code:
let jwtEncoder = JWTEncoder(jwtSigner: jwtSigner)
let jwtString = try jwtEncoder.encodeToString(myJWT)
let jwtDecoder = JWTDecoder(jwtVerifier: jwtVerifier)
let jwt = try jwtDecoder.decode(JWT<MyClaims>.self, fromString: jwtString)
For documentation

ffmpeg arguments with flutter for video upload to firebase

I have been trying to use ffmpeg to compress a videos file size so I can upload to firebase storage.
I've ran the code on windows cmd and it works. But when i run it on flutter the quality of the video is terrible. I have also specified many values for the -crf param but the output videos quality and file size are always the same.
int processSuccess = await _flutterFFmpeg.execute(["-i", "file1.mp4", "-crf", "23", "fileoutput.mp4"]);
I had to change the package to video as the execution would fail on the default import as it could not find the -crf param.
flutter_ffmpeg:
git:
url: git://github.com/tanersener/flutter-ffmpeg.git
ref: v0.2.1
path: packages/flutter_ffmpeg_video
Am I doing something wrong with the execution arguments or is the import I'm using not the correct package. Sorry I'm very new to ffmpeg.
Thanks for the help.
https://github.com/tanersener/flutter-ffmpeg
Ended up using flutter_video_compress for compression.
Works well https://pub.dartlang.org/packages/flutter_video_compress
I see that you are using the video package of flutter_ffmpeg which unfortunately doesn't include GPL licensed libraries like x264. If you use a GPL licensed package like min-gpl, https-gpl or full-gpl then your output video will be encoded with x264 and have better quality.
Use flutter_ffmpeg package 21-packages as per your requirement.
Configuration
In Android Edit android/build.gradle file and define package name in ext.flutterFFmpegPackage variable.
ext {
flutterFFmpegPackage = "<package name>"//e.g "full-gpl"
}

How to use install_github behind a proxy?

I've finally managed to make my proxy settings work for GitHub cloning, using the following code :
options(rsconnect.http = "internal")
Sys.setenv(http_proxy = "http://proxy.lala.blabla:8080")
Sys.setenv(https_proxy = "https://proxy.lala.blabla:8080")
I can now clone github projects using File > New Project > Version control.
But I can't install from github :'(
require(devtools)
install_github("this/that")
--> Installation failed: Could not resolve host: raw.githubusercontent.com
People seem to use the following command :
http::set_config(use_proxy(...))
But that would force me to explicitely write my login / pass, which I don't want to do. I'd rather use the default ones that are associated to
options(rsconnect.http = "internal")
How can I configure the proxy here, without writing my login/pass please ?
devtools uses httr under the hoods, see e.g. devtools:::remote_package_name.github_remote or devtools:::remote_download.github_remote.
That is why it requires you to set the proxy in the httr::set_config(httr::use_proxy(...)) way.
I would suggest that you just pick up the information from the environment variables and pass the elements to httr::set_config(httr::use_proxy(...)). Then you don't need to type your settings in the code.

base32 encode/decode on Meteor platform

For a reason I need to implement base32 encode and decode within the Meteor platform and I am having a very difficult time to find any package available for me to do it. I found one for base64, but not base32. Any pointer?
You can use all npm packages by adding a Meteor package like this one: https://atmospherejs.com/meteorhacks/npm.
Then create a 'package.json' file:
{
"base32": "0.0.6"
}
And you are ready to use the package with Meteor.npmRequire('base32') on the server side.

Resources