Beispiel #1
0
def main():
    config = conf.get_config().get('database')
    parser = argparse.ArgumentParser(description='Initialize a paste db')
    parser.add_argument('-t',
                        '--type',
                        default=config.get('dialect'),
                        help='sqlite or postgresql')
    parser.add_argument('-n',
                        '--dbname',
                        default=config.get('dbname'),
                        help='name of the database to be created')
    parser.add_argument('-d',
                        '--driver',
                        default=config.get('driver'),
                        help='database driver for sqlalchemy to use')
    parser.add_argument('-u',
                        '--username',
                        default=config.get('username'),
                        help='username to use for the database connection')
    parser.add_argument('-p',
                        '--password',
                        default=config.get('password'),
                        help='password to use for the database connection')
    parser.add_argument('-s',
                        '--server',
                        default=config.get('host'),
                        help='host of the database')
    parser.add_argument('-P',
                        '--port',
                        default=config.get('port'),
                        help='port the database listens on')
    args = parser.parse_args()
    newdb = CreateDB(dialect=args.type,
                     driver=args.driver,
                     username=args.username,
                     password=args.password,
                     host=args.server,
                     port=args.port,
                     dbname=args.dbname)
    print(newdb.create())
Beispiel #2
0
def main():
    config = conf.get_config().get('database')
    parser = argparse.ArgumentParser(description='Initialize a paste db')
    parser.add_argument('-t', '--type', default=config.get('dialect'),
                        help='sqlite or postgresql')
    parser.add_argument('-n', '--dbname', default=config.get('dbname'),
                        help='name of the database to be created')
    parser.add_argument('-d', '--driver', default=config.get('driver'),
                        help='database driver for sqlalchemy to use')
    parser.add_argument('-u', '--username', default=config.get('username'),
                        help='username to use for the database connection')
    parser.add_argument('-p', '--password', default=config.get('password'),
                        help='password to use for the database connection')
    parser.add_argument('-s', '--server', default=config.get('host'),
                        help='host of the database')
    parser.add_argument('-P', '--port', default=config.get('port'),
                        help='port the database listens on')
    args = parser.parse_args()
    newdb = CreateDB(dialect=args.type, driver=args.driver, username=args.username,
                     password=args.password, host=args.server, port=args.port,
                     dbname=args.dbname)
    print(newdb.create())
Beispiel #3
0
import io
import json
import magic
import mimetypes

from pbnh import conf
from pbnh.db import paste
from pbnh import conf
from datetime import datetime, timezone, timedelta

config = conf.get_config().get('database')

def fileData(files, addr=None, sunset=None, mimestr=None):
    try:
        buf = files.stream
        if buf and isinstance(buf, io.BytesIO) or isinstance(buf,
                io.BufferedRandom):
            data = buf.read()
            mime = getMime(data=data, mimestr=mimestr)
            with paste.Paster(dialect=config.get('dialect'), dbname=config.get('dbname'),
                              driver=config.get('driver'), host=config.get('host'),
                              password=config.get('password'), port=config.get('port'),
                              username=config.get('username')) as pstr:
                j = pstr.create(data, mime=mime, ip=addr,
                                sunset=sunset)
                return json.dumps(j)
    except IOError as e:
        return 'caught exception in filedata' + str(e)
    return 'File save error'

def stringData(inputstr, addr=None, sunset=None, mime=None):
Beispiel #4
0
#!/usr/bin/python3
import pycurl
import unittest
import json
import hashlib

from pbnh import conf

config = conf.get_config().get('server')
host = config.get('bind_ip')
port = config.get('bind_port')
URL = 'http://{}:{}/'.format(host, port)


class TestPost(unittest.TestCase):
    def setUp(self):
        self.c = pycurl.Curl()
        self.c.setopt(pycurl.URL, URL)
        pass

    def tearDown(self):
        self.c.close()
        pass

    def test_hash_string(self):
        #c = pycurl.Curl()
        data = [('content', 'abc')]
        ret = []
        self.c.setopt(pycurl.HTTPPOST, data)
        self.c.setopt(pycurl.WRITEFUNCTION, ret.append)
        self.c.perform()
Beispiel #5
0
def getConfig():
    if app.config.get('CONFIG'):
        return app.config.get('CONFIG').get('database')
    else:
        return conf.get_config().get('database')
Beispiel #6
0
import io
import re

from datetime import datetime, timezone, timedelta
from docutils.core import publish_parts
from flask import request, send_file, render_template, Response, send_from_directory, redirect
from sqlalchemy import exc
from werkzeug.datastructures import FileStorage

from pbnh.app import app
from pbnh.app import util
from pbnh.db import paste
from pbnh import conf

config = conf.get_config().get('database')


@app.route("/", methods=["GET"])
def hello():
    return render_template('index.html')


@app.route("/test", methods=["GET"])
def testing():
    return render_template('test.html')


@app.route("/about.md", methods=["GET"])
def about():
    f = open('pbnh/app/static/about.md', 'r')
    data = f.read()
Beispiel #7
0
def getConfig():
    if app.config.get('CONFIG'):
        return app.config.get('CONFIG').get('database')
    else:
        return conf.get_config().get('database')
Beispiel #8
0
#!/usr/bin/python3
import pycurl
import unittest
import json
import hashlib

from pbnh import conf

config = conf.get_config().get('server')
host = config.get('bind_ip')
port = config.get('bind_port')
URL = 'http://{}:{}/'.format(host, port)

class TestPost(unittest.TestCase):
    def setUp(self):
        self.c = pycurl.Curl()
        self.c.setopt(pycurl.URL, URL)
        pass

    def tearDown(self):
        self.c.close()
        pass

    def test_hash_string(self):
        #c = pycurl.Curl()
        data = [('content', 'abc')]
        ret = []
        self.c.setopt(pycurl.HTTPPOST, data)
        self.c.setopt(pycurl.WRITEFUNCTION, ret.append)
        self.c.perform()
        r = ret.pop()