mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Python code passed linter
This commit is contained in:
parent
2b2ab65b73
commit
53a7b886fe
@ -19,7 +19,7 @@ PASTE_FILES_ROOT = os.path.join(STATIC_FILES_ROOT, 'content')
|
|||||||
# You can also specify them using the --host and --port script options
|
# You can also specify them using the --host and --port script options
|
||||||
# which have priority on these settings
|
# which have priority on these settings
|
||||||
HOST = "127.0.0.1"
|
HOST = "127.0.0.1"
|
||||||
PORT= "8000"
|
PORT = "8000"
|
||||||
|
|
||||||
# User and group the server should run as. Set to None if it should be the
|
# User and group the server should run as. Set to None if it should be the
|
||||||
# current user. Some OS don't support it and if so, it will be ignored.
|
# current user. Some OS don't support it and if so, it will be ignored.
|
||||||
|
@ -21,7 +21,7 @@ PASTE_FILES_ROOT = os.path.join(STATIC_FILES_ROOT, 'content')
|
|||||||
# You can also specify them using the --host and --port script options
|
# You can also specify them using the --host and --port script options
|
||||||
# which have priority on these settings
|
# which have priority on these settings
|
||||||
HOST = "127.0.0.1"
|
HOST = "127.0.0.1"
|
||||||
PORT= "8000"
|
PORT = "8000"
|
||||||
|
|
||||||
# User and group the server should run as. Set to None if it should be the
|
# User and group the server should run as. Set to None if it should be the
|
||||||
# current user. Some OS don't support it and if so, it will be ignored.
|
# current user. Some OS don't support it and if so, it will be ignored.
|
||||||
@ -40,4 +40,3 @@ MENU = (
|
|||||||
# browser
|
# browser
|
||||||
MAX_SIZE = 1024 * 500
|
MAX_SIZE = 1024 * 500
|
||||||
MAX_SIZE_KB = int(math.ceil(MAX_SIZE / 1024.0))
|
MAX_SIZE_KB = int(math.ceil(MAX_SIZE / 1024.0))
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class Paste(object):
|
|||||||
self.comments = comments
|
self.comments = comments
|
||||||
|
|
||||||
if isinstance(self.content, unicode):
|
if isinstance(self.content, unicode):
|
||||||
self.content = self.content.encode('utf8')
|
self.content = self.content.encode('utf8')
|
||||||
|
|
||||||
self.expiration = self.get_expiration(expiration)
|
self.expiration = self.get_expiration(expiration)
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class Paste(object):
|
|||||||
content = paste.next().strip()
|
content = paste.next().strip()
|
||||||
comments = paste.read()[:-1] # remove the last coma
|
comments = paste.read()[:-1] # remove the last coma
|
||||||
if "burn_after_reading" not in str(expiration):
|
if "burn_after_reading" not in str(expiration):
|
||||||
expiration = datetime.strptime(expiration,'%Y-%m-%d %H:%M:%S.%f')
|
expiration = datetime.strptime(expiration, '%Y-%m-%d %H:%M:%S.%f')
|
||||||
|
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
raise TypeError(u'File %s is malformed' % path)
|
raise TypeError(u'File %s is malformed' % path)
|
||||||
@ -158,7 +158,7 @@ class Paste(object):
|
|||||||
f.write(unicode(self.expiration) + '\n')
|
f.write(unicode(self.expiration) + '\n')
|
||||||
f.write(self.content + '\n')
|
f.write(self.content + '\n')
|
||||||
if self.comments:
|
if self.comments:
|
||||||
f.write(comments)
|
f.write(self.comments)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import settings
|
|
||||||
import glob
|
import glob
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
@ -28,8 +26,8 @@ def drop_privileges(user=None, group=None, wait=5):
|
|||||||
user = coerce_user(user)
|
user = coerce_user(user)
|
||||||
group = coerce_group(group)
|
group = coerce_group(group)
|
||||||
|
|
||||||
lock_files = glob.glob(os.path.join(tempfile.gettempdir(),
|
lock_files = glob.glob(os.path.join(tempfile.gettempdir(),
|
||||||
'bottle.*.lock'))
|
'bottle.*.lock'))
|
||||||
for lock_file in lock_files:
|
for lock_file in lock_files:
|
||||||
os.chown(lock_file, user, group)
|
os.chown(lock_file, user, group)
|
||||||
|
|
||||||
|
16
start.py
16
start.py
@ -9,9 +9,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import hashlib
|
|
||||||
import thread
|
import thread
|
||||||
import math
|
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
@ -22,8 +20,7 @@ sys.path.insert(0, os.path.dirname(settings.ROOT_DIR))
|
|||||||
sys.path.append(os.path.join(settings.ROOT_DIR, 'libs'))
|
sys.path.append(os.path.join(settings.ROOT_DIR, 'libs'))
|
||||||
|
|
||||||
import bottle
|
import bottle
|
||||||
from bottle import (Bottle, route, run, abort, error,
|
from bottle import (Bottle, run, static_file, view, request)
|
||||||
static_file, debug, view, request)
|
|
||||||
|
|
||||||
import clize
|
import clize
|
||||||
|
|
||||||
@ -35,9 +32,10 @@ from src.utils import drop_privileges, dmerge
|
|||||||
app = Bottle()
|
app = Bottle()
|
||||||
|
|
||||||
global_vars = {
|
global_vars = {
|
||||||
'settings' : settings
|
'settings': settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@view('home')
|
@view('home')
|
||||||
def index():
|
def index():
|
||||||
@ -75,7 +73,6 @@ def create_paste():
|
|||||||
@view('paste')
|
@view('paste')
|
||||||
def display_paste(paste_id):
|
def display_paste(paste_id):
|
||||||
|
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
keep_alive = False
|
keep_alive = False
|
||||||
try:
|
try:
|
||||||
@ -88,7 +85,7 @@ def display_paste(paste_id):
|
|||||||
# to the paste that happens during the paste creation
|
# to the paste that happens during the paste creation
|
||||||
try:
|
try:
|
||||||
keep_alive = paste.expiration.split('#')[1]
|
keep_alive = paste.expiration.split('#')[1]
|
||||||
keep_alive = datetime.strptime(keep_alive,'%Y-%m-%d %H:%M:%S.%f')
|
keep_alive = datetime.strptime(keep_alive, '%Y-%m-%d %H:%M:%S.%f')
|
||||||
keep_alive = now < keep_alive + timedelta(seconds=10)
|
keep_alive = now < keep_alive + timedelta(seconds=10)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
keep_alive = False
|
keep_alive = False
|
||||||
@ -106,11 +103,13 @@ def display_paste(paste_id):
|
|||||||
context = {'paste': paste, 'keep_alive': keep_alive}
|
context = {'paste': paste, 'keep_alive': keep_alive}
|
||||||
return dmerge(context, global_vars)
|
return dmerge(context, global_vars)
|
||||||
|
|
||||||
|
|
||||||
@app.error(404)
|
@app.error(404)
|
||||||
@view('404')
|
@view('404')
|
||||||
def error404(code):
|
def error404(code):
|
||||||
return global_vars
|
return global_vars
|
||||||
|
|
||||||
|
|
||||||
@clize.clize
|
@clize.clize
|
||||||
def runserver(host=settings.HOST, port=settings.PORT, debug=settings.DEBUG,
|
def runserver(host=settings.HOST, port=settings.PORT, debug=settings.DEBUG,
|
||||||
serve_static=settings.DEBUG, user=settings.USER,
|
serve_static=settings.DEBUG, user=settings.USER,
|
||||||
@ -131,8 +130,5 @@ def runserver(host=settings.HOST, port=settings.PORT, debug=settings.DEBUG,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
clize.run(runserver)
|
clize.run(runserver)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*global sjcl:true, jQuery:true, $:true, lzw:true, zerobin:true, ZeroClipboard:true, vizhash:true, prettyPrint:true */
|
/*global sjcl:true, jQuery:true, $:true, lzw:true, zerobin:true, ZeroClipboard:true, vizhash:true, prettyPrint:true, confirm:true */
|
||||||
;(function(){
|
;(function(){
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user