-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start creating sample python package with https post request Signed-off-by: Elaine Chien <[email protected]> * decode output Signed-off-by: Elaine Chien <[email protected]> * Revise README and Makefile Signed-off-by: Elaine Chien <[email protected]> * spelling Signed-off-by: Elaine Chien <[email protected]> * Add https post request call to install and import phases Signed-off-by: Elaine Chien <[email protected]> * Remove requirements.txt * Change function names to use underscores Signed-off-by: Elaine Chien <[email protected]> * Add newline Signed-off-by: Elaine Chien <[email protected]> * Remove license and just defer to main package analysis license Signed-off-by: Elaine Chien <[email protected]> --------- Signed-off-by: Elaine Chien <[email protected]> Co-authored-by: Elaine Chien <[email protected]> Co-authored-by: Caleb Brown <[email protected]>
- Loading branch information
1 parent
5e36625
commit 93adcac
Showing
5 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Sample Python package | ||
|
||
This package will simulate different scenarios to test package analysis on. | ||
|
||
To use this package for local analysis, build this package by running | ||
`python3 -m build` in this directory. The package will be located in the dist/ | ||
folder. | ||
|
||
The same license for the rest of the package analysis project applies to this package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[build-system] | ||
requires = ["setuptools", "setuptools-scm"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "sample_python_package" | ||
version = "0.0.1" | ||
authors = [ | ||
{ name="OpenSSF <[email protected]>" }, | ||
] | ||
description = "A small example package" | ||
readme = "README.md" | ||
requires-python = ">=3.7" | ||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Operating System :: OS Independent", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import sys | ||
import os | ||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
sys.path.append(SCRIPT_DIR) | ||
|
||
from setuptools import setup, find_packages | ||
from src.example import * | ||
|
||
setup(name="sample_python_package", | ||
packages=find_packages(),) | ||
|
||
send_https_post_request("setup.py") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import sys | ||
import os | ||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
sys.path.append(SCRIPT_DIR) | ||
|
||
from example import * | ||
|
||
send_https_post_request("__init__.py") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import http.client | ||
import json | ||
|
||
# Sends an HTTPS post request and prints out the response. | ||
def send_https_post_request(location: str) -> None: | ||
host = "www.httpbin.org" | ||
conn = http.client.HTTPSConnection(host) | ||
data = {'text': 'Sending data through HTTPS from: ' + location} | ||
json_data = json.dumps(data) | ||
conn.request("POST", "/post", json_data, headers={"Host": host}) | ||
response = conn.getresponse() | ||
print(response.read().decode()) | ||
|
||
def main(): | ||
send_https_post_request("main function") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |