From e383a7342551f8b87b89e880afa29dab1cebbded Mon Sep 17 00:00:00 2001 From: Arthur Bols Date: Sat, 13 Mar 2021 13:13:36 +0100 Subject: [PATCH] Initial commit --- .gitignore | 214 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 16 ++++ client.py | 25 ++++++ http/__init__.py | 0 requirements.txt | 1 + server.py | 1 + 6 files changed, 257 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 client.py create mode 100644 http/__init__.py create mode 100644 requirements.txt create mode 100644 server.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..114b4ea --- /dev/null +++ b/.gitignore @@ -0,0 +1,214 @@ +# Created by .ignore support plugin (hsz.mobi) +### Python template +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + diff --git a/README.md b/README.md new file mode 100644 index 0000000..1957c4d --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Computer Networks practicum 2021 + +## Setup + +### Create the virtual environment +```shell +virtualenv venv +``` +### Activate the virtual environment +```shell +source venv/bin/activate +``` +### Install requirements +```shell +pip install -r requirements.txt +``` diff --git a/client.py b/client.py new file mode 100644 index 0000000..94a5d7b --- /dev/null +++ b/client.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +import argparse +import logging +import sys + +def main(): + parser = argparse.ArgumentParser(description='HTTP Client') + parser.add_argument("--verbose", "-v", action='count', default=0, help="Increase verbosity level of logging") + parser.add_argument("--command", "-c", help="HEAD, GET, PUT or POST", default="GET") + parser.add_argument("--port", "-p", help="The port used to connect with the server", default=80) + parser.add_argument("URI", help="The URI to connect to") + + arguments = parser.parse_args() + + logging.basicConfig(level=logging.ERROR - (10 * arguments.verbose)) + logging.debug("Arguments: %r", arguments) + raise Exception("dsfgsfsd") + + +try: + main() +except Exception as e: + print("[ABRT] Internal error: "+str(e), file=sys.stderr) + logging.debug("Internal error", exc_info=e) + sys.exit(70) \ No newline at end of file diff --git a/http/__init__.py b/http/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..307313b --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +sockets==1.0.0 diff --git a/server.py b/server.py new file mode 100644 index 0000000..5f7ce86 --- /dev/null +++ b/server.py @@ -0,0 +1 @@ +#!/usr/bin/env python3 \ No newline at end of file