From e02bb92f2968ff93278003f1f49e3bfeb5812595 Mon Sep 17 00:00:00 2001 From: chee Date: Sun, 8 Nov 2020 21:32:21 +0000 Subject: [PATCH] initial commit --- .gitignore | 2 + LICENSE | 30 ++++++++++ Makefile | 7 +++ readme.org | 3 + requirements.txt | 3 + setup.py | 17 ++++++ share/__init__.py | 0 share/__main__.py | 69 ++++++++++++++++++++++ share/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 134 bytes share/__pycache__/__main__.cpython-38.pyc | Bin 0 -> 1416 bytes share/__pycache__/getseq.cpython-38.pyc | Bin 0 -> 935 bytes share/getseq.py | 34 +++++++++++ share_chee.egg-info/PKG-INFO | 15 +++++ share_chee.egg-info/SOURCES.txt | 8 +++ share_chee.egg-info/dependency_links.txt | 1 + share_chee.egg-info/top_level.txt | 1 + 16 files changed, 190 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 readme.org create mode 100644 requirements.txt create mode 100644 setup.py create mode 100755 share/__init__.py create mode 100755 share/__main__.py create mode 100644 share/__pycache__/__init__.cpython-38.pyc create mode 100644 share/__pycache__/__main__.cpython-38.pyc create mode 100644 share/__pycache__/getseq.cpython-38.pyc create mode 100755 share/getseq.py create mode 100644 share_chee.egg-info/PKG-INFO create mode 100644 share_chee.egg-info/SOURCES.txt create mode 100644 share_chee.egg-info/dependency_links.txt create mode 100644 share_chee.egg-info/top_level.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..edd9d60 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +dist/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b3f6a98 --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +https://creativecommons.org/share-your-work/public-domain/cc0/ + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: + + the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; + moral rights retained by the original author(s) and/or performer(s); + publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; + rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; + rights protecting the extraction, dissemination, use and reuse of data in a Work; + database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and + other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. + +4. Limitations and Disclaimers. + + No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. + Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. + Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. + Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c024765 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +init: + pip install -r requirements.txt + +test: + py.test tests + +.PHONY: init test diff --git a/readme.org b/readme.org new file mode 100644 index 0000000..6dd7701 --- /dev/null +++ b/readme.org @@ -0,0 +1,3 @@ +* Share + +share files on share.snoot.club diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0521301 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +python-magic==0.4.18 +python-slugify==4.0.1 +text-unidecode==1.3 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..40dd662 --- /dev/null +++ b/setup.py @@ -0,0 +1,17 @@ +import setuptools + +with open("readme.org", "r") as fh: + long_description = fh.read() + +setuptools.setup( + name="share-chee", + version="0.0.0", + author="chee", + author_email="chee@snoot.club", + description="share to share.snoot.club", + long_description=long_description, + long_description_content_type="text/org", + url="https://git.snoot.club/chee/share", + packages=setuptools.find_packages(), + python_requires=">= 3.6" +) diff --git a/share/__init__.py b/share/__init__.py new file mode 100755 index 0000000..e69de29 diff --git a/share/__main__.py b/share/__main__.py new file mode 100755 index 0000000..595e9d2 --- /dev/null +++ b/share/__main__.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +import argparse +import mimetypes +from subprocess import PIPE +import magic +import subprocess +import os +from slugify import slugify +from .getseq import getseq + +parser = argparse.ArgumentParser() +parser.add_argument( + "file", + help="the file to upload to the server" +) +parser.add_argument( + "-s", + "--server", + help="ssh server", + default="snoot.club" +) +parser.add_argument( + "-u", + "--user", + help="ssh user", + default="share" +) +parser.add_argument( + "-d", + "--server-root", + help="directory root", + default="/snoots/share/share.snoot.club/website" +) +parser.add_argument( + "-p", + "--public-root", + help="the prefix for the public url", + default="https://share.snoot.club" +) + +args = parser.parse_args() + +mimetypes.init() + +if args.file.startswith("/tmp/.psub") or args.file.startswith("/dev/fd"): + prefix = getseq() + head = open(args.file, "rb").read(2048) + ext = mimetypes.guess_extension(magic.from_buffer(head, True)) + output_filename = f"{prefix}{ext}" +else: + [name, ext] = os.path.splitext(os.path.basename(args.file)) + output_filename = f"{slugify(name)}{ext}" + +dirname = getseq() + +ssh_target = f"{args.user}@{args.server}" + +destdir = f"{args.server_root}/{dirname}" +subprocess.run(["ssh", ssh_target, "mkdir", "-p", destdir]) +subprocess.run([ + "rsync", + "-zL", + "--progress", + "--chmod=a+rw", + args.file, + f"{ssh_target}:{destdir}/{output_filename}" +], stdout=PIPE) + +print(f"{args.public_root}/{dirname}/{output_filename}") diff --git a/share/__pycache__/__init__.cpython-38.pyc b/share/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fbbbd2c4824682ddf0908991d23c05c2d179c075 GIT binary patch literal 134 zcmWIL<>g`kf~MpZ@gVv!h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o2B-KO;XkRX;f+ xHC4Z$C_gJTxujUXI3uwr6-vg(XXa&=#K-FuRNmsS$<0qG%}KQb8S)v3836RJ9b5na literal 0 HcmV?d00001 diff --git a/share/__pycache__/__main__.cpython-38.pyc b/share/__pycache__/__main__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..af5efbec19a925684d6eab49cecced68c6c875a6 GIT binary patch literal 1416 zcma)5OK;>v5bo~rD>IXKHp%9(nPeXj&}8l_K+Ayx5<-!HOAE>JOx4Ud>lfYjCh;`~ zPAhSbkY;Xh=g80C2S;(E_BeXAeXOHW3&*aYeoPRImKE*k>f5YF$);kD=Pt1fIe(cn&YjE_g&4AK-DFw?ldM#K9JPSl8|; zMLfG_B;MM8LoC3*VW+3>Okck~<&|~*<@pyRT^$vZaD4raTFc0GCYWpdp|Zwdgk>+E zV$W#3Jna=(lm=ilgKAW7P#LBvMp-HPy7c<}1})oKPwyf~Ptr6$8%4$NR4A9Wsa(Ku zP((Rp6{XYf7nD|dCdX*f*3&>CIiXy>r|c^tDOVs=ILcFX-K*^vgPL3q>WpSRd%xe{ z5{Ej>4OM2SvSJv8qlW6xTq09A4zGISRMmHC{Jla&4MXNJ_U(edTJV8v(Pb(-eog09C# z_%!%fT`u@bQ+=I7TI8qCr5C747ATE!DGp=IuQSwDoA#vi5oIf33Tel|Bpg*D)v86d zqQ95PmCx0rh%w2}O}>&&&7)*D0Pu;n_Q`gQ8e3PES)~;wVXhp*+tzuYa(x-*)5>Xz zR9R_;No6Sv!1O!-xjHH6BtBl{nCLJ~WM{0>*dG?-F>Tu-T&~h>vLg4*3?)H~m6Zj= z>FF$@zFg&%Hw^Thr}n#4u_mw{1*aJ(X$H!tGtqR)PJ{Vo0wj$R)htw1OBG3FXDUo6 zqG@Cu@hek3QyQ}@)|)x;{Wu5{-#^Q)EAJC(K@s6+rl9(Y7LR+pOJ5_q!s8YfT>Rr$ qwKV$Qj`Kfs*At%D;||}TcZIYy;fM{f# literal 0 HcmV?d00001 diff --git a/share/__pycache__/getseq.cpython-38.pyc b/share/__pycache__/getseq.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a5b14e61b99aa44bb1cc8735acec37eb3c2edc52 GIT binary patch literal 935 zcma)4y>8nu5av-omMz;sg91sHjs*m?^$Qe5f$m;{E?NXt$4LH>f?AJb)yDKwt(Tn)u=)x zF?=Cfh=-MnVLVhL6{ukgEl_^A5Yfp4RTt9;tefh59Y6n^;bmUT7t69*U1`&-H#fJj zm#SHPopI>#;1)j8G~8(;cF@SLl=L2^kz;+GR#=zT&x(4MDeJH6jar&}p?ehF!DBQj z>QYUzLaE70*K?IMW@3s|tKXQb#;B{es~hWezXx26)D!}ApYVSvX{H)E+9jhs0z1g+ z%G6a_HRg%X-s2*+e>e|m`KKoPf7RrEIvHM)gRm0~w4#wTk8JL-G?AQI;$hu+J*zZl z>)QAy19wwv98-v45a2$2KQ(VX072HN!2vYb=N3CQugTdGA9@w1D0gBD%%B0*^nI;)Z-8h5u~9dlze6W08CG{^6?=v3kU4nJ0DsglGxRM|SSs?n!(YQ2?a l|L~fQE-!dj)_A>C?>WCYCkS9DNkADm^!3L+tzk?%zW@N+vTXnW literal 0 HcmV?d00001 diff --git a/share/getseq.py b/share/getseq.py new file mode 100755 index 0000000..f0b6b41 --- /dev/null +++ b/share/getseq.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +import random +from sys import argv + +consonants = "bcdfghjklmnpqrstvwyz" +vowels = "aeiou" + +def vowel(): + return random.choice(vowels) + +def consonant(): + return random.choice(consonants) + +def word(): + return ''.join([ + consonant(), + vowel(), + consonant(), + vowel(), + consonant() + ]) + +def getseq(length=1, words=[]): + if length == 0: + return '-'.join(words) + else: + return getseq(length - 1, [word()] + words) + +if __name__ == "__main__": + if len(argv) > 1: + length = int(argv[1]) + else: + length = 1 + print(getseq(length)) diff --git a/share_chee.egg-info/PKG-INFO b/share_chee.egg-info/PKG-INFO new file mode 100644 index 0000000..a48a326 --- /dev/null +++ b/share_chee.egg-info/PKG-INFO @@ -0,0 +1,15 @@ +Metadata-Version: 2.1 +Name: share-chee +Version: 0.0.0 +Summary: share to share.snoot.club +Home-page: https://git.snoot.club/chee/share +Author: chee +Author-email: chee@snoot.club +License: UNKNOWN +Description: * Share + + share files on share.snoot.club + +Platform: UNKNOWN +Requires-Python: >= 3.6 +Description-Content-Type: text/org diff --git a/share_chee.egg-info/SOURCES.txt b/share_chee.egg-info/SOURCES.txt new file mode 100644 index 0000000..9dae6c1 --- /dev/null +++ b/share_chee.egg-info/SOURCES.txt @@ -0,0 +1,8 @@ +setup.py +share/__init__.py +share/__main__.py +share/getseq.py +share_chee.egg-info/PKG-INFO +share_chee.egg-info/SOURCES.txt +share_chee.egg-info/dependency_links.txt +share_chee.egg-info/top_level.txt \ No newline at end of file diff --git a/share_chee.egg-info/dependency_links.txt b/share_chee.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/share_chee.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/share_chee.egg-info/top_level.txt b/share_chee.egg-info/top_level.txt new file mode 100644 index 0000000..75701e4 --- /dev/null +++ b/share_chee.egg-info/top_level.txt @@ -0,0 +1 @@ +share