Metadata-Version: 2.1
Name: fileware
Version: 0.1.0
Summary: Python module to, serve files in physical memory to localhost and tunnel to a public endpoint.
Home-page: https://github.com/thevickypedia/fileware
Author: Vignesh Sivanandha Rao
Author-email: svignesh1793@gmail.com
License: UNKNOWN
Project-URL: Docs, https://thevickypedia.github.io/fileware
Project-URL: Bug Tracker, https://github.com/thevickypedia/fileware/issues
Keywords: personal-cloud,file-server,ssl
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE

**Versions Supported**

![Python](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10-blue)

**Language Stats**

![Language count](https://img.shields.io/github/languages/count/thevickypedia/fileware)
![Code coverage](https://img.shields.io/github/languages/top/thevickypedia/fileware)

**Repo Stats**

[![GitHub](https://img.shields.io/github/license/thevickypedia/fileware)](https://github.com/thevickypedia/fileware/blob/main/LICENSE)
[![GitHub repo size](https://img.shields.io/github/repo-size/thevickypedia/fileware)](https://api.github.com/repos/thevickypedia/fileware)
[![GitHub code size](https://img.shields.io/github/languages/code-size/thevickypedia/fileware)](https://api.github.com/repos/thevickypedia/fileware)
[![LOC](https://img.shields.io/tokei/lines/github/thevickypedia/fileware)](https://api.github.com/repos/thevickypedia/fileware)

**Code Stats**

![Modules](https://img.shields.io/github/search/thevickypedia/fileware/module)
![Python](https://img.shields.io/github/search/thevickypedia/fileware/.py)

**Activity**

[![GitHub Repo created](https://img.shields.io/date/1618966420)](https://api.github.com/repos/thevickypedia/fileware)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/thevickypedia/fileware)](https://api.github.com/repos/thevickypedia/fileware)
[![GitHub last commit](https://img.shields.io/github/last-commit/thevickypedia/fileware)](https://api.github.com/repos/thevickypedia/fileware)

**Build Status**

[![pypi-publish](https://github.com/thevickypedia/gmail-connector/actions/workflows/python-publish.yml/badge.svg)](https://github.com/thevickypedia/gmail-connector/actions/workflows/python-publish.yml)
[![pages-build-deployment](https://github.com/thevickypedia/gmail-connector/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/thevickypedia/gmail-connector/actions/workflows/pages/pages-build-deployment)

# FileWare
Set up a file server to access files in local machine from anywhere on the internet.

### Setup
**Environment Variables:**

- `username`: Username to confirm identity. Defaults to user profile name.
- `password`: Password for authentication. Defaults to `FileServer`
- `port`: Port number to serve. Defaults to `4443`.
- `host_path`: Path which is to be hosted. Defaults to `home` page.

**To enable notifications during connections:**

- `gmail_user`: Username for a gmail account.
- `gmail_pass`: Password for the gmail account.
- `recipient`: Recipient email address.

**To host on a public facing URL:**
- `ngrok_auth`: Ngrok token.

### Usage

```shell
python3 -m pip install fileware
```

**With Threading**
```python
from threading import Thread

from fileware import FileWare

file_server = FileWare()
response = file_server.initiate_connection()
print(response.url)

thread = Thread(target=file_server.serve, kwargs={'http_server': response.server, 'socket_connection': response.socket})
thread.start()
```

**Without Threading**
```python
from fileware import FileWare

file_server = FileWare()
response = file_server.initiate_connection()
print(response.url)

file_server.serve(http_server=response.server, socket_connection=response.socket)
```

> Env vars can be loaded by placing a .env file in current working directory.
>
> The `serve` function can also take arguments which can be used to override env vars.

**Run-book:**

https://thevickypedia.github.io/fileware/

> Generated using [`sphinx-autogen`](https://www.sphinx-doc.org/en/master/man/sphinx-autogen.html)

**Coding Standards:**

Docstring format: [`Google`](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) <br>
Styling conventions: [`PEP 8`](https://www.python.org/dev/peps/pep-0008/) <br>
Clean code with pre-commit hooks: [`flake8`](https://flake8.pycqa.org/en/latest/) and 
[`isort`](https://pycqa.github.io/isort/)

**Pre-Commit**

`pre-commit` will run `flake8` and `isort` to ensure proper coding standards along with [docs_generator](https://github.com/thevickypedia/fileware/blob/main/gen_docs.sh) 
to update the [runbook](#Run-book)

> `pip install --no-cache --upgrade sphinx pre-commit recommonmark`

> `pre-commit run --all-files`

## License & copyright

&copy; Vignesh Sivanandha Rao

Licensed under the [MIT License](https://github.com/thevickypedia/fileware/blob/main/LICENSE)


Change Log
==========

1.2.1 (02/21/2022)
------------------
- Update sender name in notifications
- Update badges in README.md
- Update build-local.sh to automatically pick repo name

1.2.0 (02/21/2022)
------------------
- Make app `Thread` compatible and create `Response` class
- Get serving URL after the connection has been initiated
- Move loggers to models.py
- Update README.md, docs, CHANGELOG and bump version

1.1.9 (02/20/2022)
------------------
- Use an __init__ file to get the startup args
- Get IP information from a function instead of a dict
- Update README.md and rename ngrok_connector.py

1.1.8 (02/20/2022)
------------------
- Update branch name in github actions
- Update README.md and CHANGELOG

1.1.7 (02/20/2022)
------------------
- Create a pypi module
- Setup github actions to auto upload to pypi
- Create a script to build pypi locally

1.1.6 (02/20/2022)
------------------
- Move all modules under a controller
- Move files into fileserver directory
- Use env.py to handle global env vars

1.1.5 (02/13/2022)
------------------
- Update project name in docs

1.1.4 (02/13/2022)
------------------
- Generate SSL certificate automatically
- Remove restart script

1.1.3 (01/27/2022)
------------------
- Force port number to be an integer
- Take username from OS module

1.1.2 (11/14/2021)
------------------
- Upgrade `sphinx` and `gmailconnector` version

1.1.1 (10/17/2021)
------------------
- Use non-routable address only when ngrok is running
- Using local IP allows usage without internet access
- Attempt notification only for login success or undefined

1.1.0 (10/12/2021)
------------------
- Avoid proxy server and use local machine IP to serve instead of localhost
- This allows access to the server within the Network range without any tunnelling

1.0.9 (10/10/2021)
------------------
- Use custom ngrok auth token if the config yaml is present and authtoken is in env vars
- Check if an existing ngrok is running and whether to use the self-signed cert
- Create _static dir if not found

1.0.8 (07/31/2021)
------------------
- Update docs with `code-block`

1.0.7 (07/30/2021)
------------------
- Add `<noscript>` for `JavaScript` disabled browsers
- Remove hard-coded version for `gmail-connector`

1.0.6 (07/30/2021)
------------------
- Auto upgrade `sphinx` before generating docs

1.0.5 (07/29/2021)
------------------
- Add a button with funny alert for session and no auth

1.0.4 (07/24/2021)
------------------
- Add markdown support for sphinx documentation

1.0.3 (07/22/2021)
------------------
- Sunset emailer.py and use self built module instead
- Reload logging module since gmail-connector uses logging
- Replace lstrip, rstrip with a generic strip
- Update docs

1.0.2 (07/12/2021)
------------------
- Check if directory exists before serving `host_path`
- Include link to logs in email body only if logs are reachable

1.0.1 (07/12/2021)
------------------
- Log when a logout has been requested
- Add attachment content in body of the email

1.0.0 (07/12/2021)
------------------
- Log https endpoint instead of http
- Update README.md

0.9.9 (07/11/2021)
------------------
- Add an option to logout from session
- Remove Helper class from volume.py
- Change env var name for host_path
- Update docs and README.md

0.9.8 (07/11/2021)
------------------
- add badges

0.9.7 (07/10/2021)
------------------
- add hyperlinks on docstrings

0.9.6 (07/10/2021)
------------------
- Restart ngrok.py in case of an active session found.
- Write url file before exiting
- On board restart.py

0.9.5 (07/10/2021)
------------------
- Check for stringified None for volume_name
- Fix upper case por in ngrok.py

0.9.4 (07/10/2021)
------------------
- Use url file creation to support functionalities in Jarvis

0.9.3 (07/10/2021)
------------------
- update README.md

0.9.2 (07/10/2021)
------------------
- Onboard docs

0.9.1 (07/10/2021)
------------------
- Update docstrings to onboard docs

0.9.0 (07/10/2021)
------------------
- Update docstrings to onboard docs

0.8.9 (07/10/2021)
------------------
- Log response when connected from same IP
- move volume.py to helper_functions

0.8.8 (07/10/2021)
------------------
- Do not notify if connected from same public ip
- Add dummy function to explain file_gatherer

0.8.7 (07/10/2021)
------------------
- Read html and write content instead of serving file

0.8.6 (07/10/2021)
------------------
- rename templates to html and move auth_server.html within

0.8.5 (07/09/2021)
------------------
- refactor files and update file refs

0.8.4 (07/09/2021)
------------------
- update README.md

0.8.3 (07/09/2021)
------------------
- Automatically fetch global (ngrok) endpoint
- authserver.py to work with ngrok.py and ngrok_fetcher.py
- Set default port in ngrok.py
- Remove logging from ngrok_fetcher.py and make get_ngrok module to help authserver.py

0.8.2 (07/09/2021)
------------------
- Remove redundancy on socket module

0.8.1 (07/09/2021)
------------------
- Remove hard coded IP urls from JavaScript

0.8.0 (07/09/2021)
------------------
- Sunset legacy TCP connection and all code references

0.7.9 (07/09/2021)
------------------
- Add an ultimate guide to check the ngrok public url
- Remove manual url file creation from ngrok.py
- Update .gitignore

0.7.8 (07/09/2021)
------------------
- Avoid multiple notifications for same action type

0.7.7 (07/09/2021)
------------------
- Onboard Emailer to notify client information
- Add direct access to logs in the email footer

0.7.6 (07/09/2021)
------------------
- Get IP info of clients who lands on any html page
- Store client IP info in a yaml file
- do_AUTHHEAD() -> do_AUTH()
- Update docstrings, .gitignore and requirements.txt

- fileLogger: Writes the log information only to the log file.
- consoleLogger: Writes the log information only in stdout.
- rootLogger: Logs the entry in both stdout and log file.

0.7.5 (07/08/2021)
------------------
- Add multiple log handlers - file, console and root

- This will also avoid FileNotFoundError and NotADirectoryError

0.7.4 (07/07/2021)
------------------
- If target_path is dir instead of endswith html

0.7.3 (07/07/2021)
------------------
- Add _TEMP to index files to avoid page hosting
- Revert changes to index.html files when server is stopped

0.7.2 (07/07/2021)
------------------
- Serve html file from its source instead of copying

0.7.1 (07/07/2021)
------------------
- fix the mess on host_dir

0.7.0 (07/07/2021)
------------------
- Onboard a welcome screen before showing files content
- Add optional host_dir method for server_function

0.6.9 (07/07/2021)
------------------
- Create html files to serve in case of login issues
- Encode html files' data to be written on server
- Remove write operation for incorrect creds, as this never gets written

0.6.8 (07/07/2021)
------------------
- Write html to request handler

0.6.7 (07/06/2021)
------------------
- Use os.path.sep instead of '/'

0.6.6 (07/06/2021)
------------------
- Run without SSL if .pem files are not found
- Handle BrokenPipeError and log it
- Check for len(args) in log_message to make it simple

0.6.5 (07/06/2021)
------------------
- Better logging
- Minor performance tweaks

0.6.4 (07/05/2021)
------------------
- Reset server side auth headers after timeout
- Provoke client side authentication

0.6.3 (07/05/2021)
------------------
- Add no-cache and clear-site-data headers

0.6.2 (07/05/2021)
------------------
- Exit if username and password is not set
- Use a default port
- Fix logging on 404

0.6.1 (07/05/2021)
------------------
- Prompt SSL cert creation
- Use HTTPServer instead of test in http module
- Wrap socket to ssl cert
- Include line number in print statements

0.6.0 (07/04/2021)
------------------
- Add logger
- Add doc strings
- Log unauthenticated username & password

0.5.9 (07/04/2021)
------------------
- onboard auth server

0.5.8 (07/04/2021)
------------------
- fix imports

0.5.7 (06/29/2021)
------------------
- parse url to read credentials

0.5.6 (05/20/2021)
------------------
- minor bug fixes

0.5.5 (04/30/2021)
------------------
- improve logging to generic way instead of module based

0.5.4 (04/30/2021)
------------------
- improve logging with respect to function name and file name

0.5.3 (04/30/2021)
------------------
- update README.md and requirements.txt

0.5.2 (04/29/2021)
------------------
- write url to a file to help Jarvis trigger ngrok

0.5.1 (04/29/2021)
------------------
- add requirements.txt

0.5.0 (04/29/2021)
------------------
- kill ngrok and close socket properly upon exit

0.4.9 (04/29/2021)
------------------
- add logger and more end to end socket connection

0.4.8 (04/29/2021)
------------------
- basic ngrok integration

0.4.7 (04/26/2021)
------------------
- stop volume usage gracefully

0.4.6 (04/26/2021)
------------------
- avoid using socket module repeatedly

0.4.5 (04/26/2021)
------------------
- split js from html and update .gitignore

0.4.4 (04/24/2021)
------------------
- avoid unnecessary repetition in logs and add |bypass| to get access using right creds

0.4.3 (04/24/2021)
------------------
- brute force to exit threads, add display statements for startup and shutdown

0.4.2 (04/24/2021)
------------------
- remove thread for kick off and add logger for re-auth wait time

0.4.1 (04/24/2021)
------------------
- add another layer of page refresh from server
- increase width of username and password fields

0.4.0 (04/23/2021)
------------------
- make it complex

0.3.9 (04/23/2021)
------------------
- mound and unmount disk programmatically

0.3.8 (04/23/2021)
------------------
- unmount disk automatically

0.3.7 (04/23/2021)
------------------
- get disk info post killing usage

0.3.6 (04/23/2021)
------------------
- brute force lsof for much quicker results

0.3.5 (04/23/2021)
------------------
- use lsof to find appropriate volume usage

0.3.4 (04/23/2021)
------------------
- onboard a handy script to kill volume usage

0.3.3 (04/22/2021)
------------------
- refresh page on first visit to avoid unauth access while using multiple sessions

0.3.2 (04/22/2021)
------------------
- update todos.py with a new long term plan

0.3.1 (04/22/2021)
------------------
- add LICENSE and update README.md

0.3.0 (04/22/2021)
------------------
- add todos for future iteration

0.2.9 (04/22/2021)
------------------
- add a runbook/user guide

0.2.8 (04/22/2021)
------------------
- block on failed auth and unblock after timed wait

0.2.7 (04/22/2021)
------------------
- add some detailing to the timer

0.2.6 (04/22/2021)
------------------
- make sure the timer doesn't reset on page refresh

0.2.5 (04/22/2021)
------------------
- display a timer to redirect to login page

0.2.4 (04/22/2021)
------------------
- add some meta tags

0.2.3 (04/22/2021)
------------------
- onboard blocker html page

0.2.2 (04/21/2021)
------------------
- reduce page refresh time for reload button

0.2.1 (04/21/2021)
------------------
- redirect to home page in case the auth header is lost in url

- https://docs.python.org/3/library/logging.html#logrecord-attributes

0.2.0 (04/21/2021)
------------------
- include function name in logger information

0.1.9 (04/21/2021)
------------------
- log more information on incorrect or empty credentials

0.1.8 (04/21/2021)
------------------
- add basic auth check using hyperlink from index file

0.1.7 (04/21/2021)
------------------
- handle broken pipe errors and remove log file during port busy

0.1.6 (04/21/2021)
------------------
- disable caching

0.1.5 (04/21/2021)
------------------
- gray out verify button if unsername and password fields are empty

0.1.4 (04/21/2021)
------------------
- disable scrolling and set no wrap for heading

0.1.3 (04/21/2021)
------------------
- add background and adjust margin

0.1.2 (04/21/2021)
------------------
- change font, size and background for login form

0.1.1 (04/21/2021)
------------------
- add some styling in there

0.1.0 (04/21/2021)
------------------
- basic html page for the front end

0.0.9 (04/21/2021)
------------------
- handle port in use exception

0.0.8 (04/21/2021)
------------------
- implement function level logging for visibility and restructure code

0.0.7 (04/20/2021)
------------------
- choose a repository you would like to share on internet

0.0.6 (04/20/2021)
------------------
- handle busy port errors gracefully with more information to user

0.0.5 (04/20/2021)
------------------
- solve port busy issue and implement logging

0.0.4 (04/20/2021)
------------------
- host current directory on a desired port

0.0.3 (04/20/2021)
------------------
- add .gitignore

0.0.2 (04/20/2021)
------------------
- update README.md

0.0.1 (04/20/2021)
------------------
- Initial commit


