Ejemplo n.º 1
0
def get_logger(args, name = _default_logger_name):
    try:
        import coloredlogs
        coloredlogs.install(
            isatty = True,
            show_name = False,
            show_severity = False,
            level = logging.NOTSET,
            severity_to_style = {'DEBUG': {'color': 'blue'}},
        )
    except:
        logging.basicConfig(
            stream = sys.stdout,
            format = '%(asctime)s ' + ghn() + ' %(levelname)-8s %(message)s',
            datefmt = "%Y-%m-%d %H:%M:%S",
            level = logging.NOTSET,
        )
    _set_logging_level(args.quiet, args.verbose)
    return logging.getLogger(name)
Ejemplo n.º 2
0
from flask import Flask, render_template, url_for, flash, redirect, request, jsonify
from socket import gethostbyname as ghbn, gethostname as ghn
from flask_wtf import FlaskForm
from wtforms import DateField, FloatField, SelectField, SubmitField
from wtforms.validators import DataRequired
import redis
# Imported Flask
app = Flask(__name__)
app.config['SECRET_KEY'] = 'abdallah'
# Defining ip address and port number to connect to our redis database
ip_addr = ghbn(ghn())
port_num = 6379
client = redis.Redis(host=ip_addr, port=port_num)
aed_to_usd = float(client.get('aed_to_usd').decode('utf-8'))
usd_to_aed = float(client.get('usd_to_aed').decode('utf-8'))
choice = ["USD", "AED"]
choice_edit = ["USD_TO_AED", "AED_TO_USD"]


# Creating Flask forms to pass them to our html pages
class InputDataForms(FlaskForm):
    date = DateField("Type the Date in This Format ( yyyy-mm-dd ) ",
                     validators=[DataRequired()])
    base = SelectField('base', choices=choice, validators=[DataRequired()])
    currency = SelectField('currency',
                           choices=[choice[-1], choice[0]],
                           validators=[DataRequired()])
    quantity = FloatField(f'How much would you like to convert?',
                          validators=[DataRequired()])
    submit = SubmitField('Calculate')
    edit = SubmitField('Edit conversion rates')
__version__ = '0.1'
try:
    import coloredlogs
    coloredlogs.install(
        isatty=True,
        show_name=False,
        show_severity=False,
        level=logging.NOTSET,
        severity_to_style={'DEBUG': {
            'color': 'blue'
        }},
    )
except:
    logging.basicConfig(
        stream=sys.stderr,
        format='%(asctime)s ' + ghn() + ' %(levelname)-8s %(message)s',
        datefmt="%Y-%m-%d %H:%M:%S",
        level=logging.NOTSET,
    )
log = logging.getLogger(os.path.basename(sys.argv[0]))


def clamp(low, x, high):
    return low if x < low else high if x > high else x


def unwrap(txt):
    return ' '.join(textwrap.wrap(textwrap.dedent(txt).strip()))


def set_logging_level(quiet, verbose):
Ejemplo n.º 4
0
config.bind('gs', 'set-cmd-text --space :quickmark-add {url}')
# Use uget
config.bind('<Ctrl-m>',
            "prompt-yank -s;;spawn uget-gtk --quiet --folder=Downloads " +
            "'{primary}';;mode-enter normal",
            mode='prompt')
config.bind('<Ctrl-shift-m>',
            "prompt-yank -s;;spawn uget-gtk '{primary}';;" +
            "mode-enter normal",
            mode='prompt')

currentTime = datetime.datetime.now()
c.content.blocking.enabled = True
c.content.blocking.method = "both"

if ghn() == "sbp-workstation":
    c.url.default_page = "http://intranet.cshl.edu"
    c.url.start_pages = ["http://intranet.cshl.edu"]
else:
    c.url.default_page = "https://start.duckduckgo.com/"
    c.url.start_pages = ["https://start.duckduckgo.com/"]

# base16-qutebrowser (https://github.com/theova/base16-qutebrowser)
# Base16 qutebrowser template by theova
# Tomorrow Night scheme by Chris Kempson (http://chriskempson.com)
base00 = "#1d1f21"
base01 = "#282a2e"
base02 = "#373b41"
base03 = "#969896"
base04 = "#b4b7b4"
base05 = "#c5c8c6"