summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico von Geyso <Nico.Geyso@FU-Berlin.de>2014-02-10 13:01:24 +0100
committerNico von Geyso <Nico.Geyso@FU-Berlin.de>2014-02-10 13:01:24 +0100
commiteb8b08061262da2ab8bbdc01bec86b03a17747eb (patch)
tree80cfce4cbdfe9fdf45209d43708a04a991aeb66f
parent2c8a7e6970ba2a8bf07a0e38ad1b7811bbadbb25 (diff)
downloadklausuren-eb8b08061262da2ab8bbdc01bec86b03a17747eb.tar.gz
klausuren-eb8b08061262da2ab8bbdc01bec86b03a17747eb.tar.bz2
klausuren-eb8b08061262da2ab8bbdc01bec86b03a17747eb.zip
Updated to pygit v0.20.2
-rw-r--r--app.py8
-rw-r--r--fit.py22
-rw-r--r--requirements.txt16
-rw-r--r--settings.py.sample1
4 files changed, 25 insertions, 22 deletions
diff --git a/app.py b/app.py
index 8d2a5d4..e054c8f 100644
--- a/app.py
+++ b/app.py
@@ -18,6 +18,13 @@ sys.setdefaultencoding('utf-8')
app = Flask(__name__)
app.config.from_pyfile('settings.py')
+if not app.debug:
+ import logging
+ from logging.handlers import RotatingFileHandler
+ file_handler = RotatingFileHandler(app.config['LOG_FILE_PATH'])
+ file_handler.setLevel(logging.WARNING)
+ app.logger.addHandler(file_handler)
+
# populate Module-List
fit = {}
for i, study in enumerate(app.config['STUDIES'].items()):
@@ -135,6 +142,7 @@ def study_index(study, module=None):
def index():
get_img_path = lambda x: os.path.join('images', x +'.png')
studies = [(name,get_img_path(name)) for name,m in app.config['STUDIES'].items()]
+ print(fit)
return render_template(
'index.html',
diff --git a/fit.py b/fit.py
index 9c9ccae..4725880 100644
--- a/fit.py
+++ b/fit.py
@@ -4,7 +4,7 @@
import os, time
import collections
-from pygit2 import init_repository, Signature
+from pygit2 import init_repository, Signature, GIT_FILEMODE_TREE, GIT_FILEMODE_BLOB
from binascii import b2a_hex
@@ -57,9 +57,9 @@ class Fit:
# similiar to `git update-server-info`
info_refs_path = os.path.join(self.repo.path, 'info', 'refs')
with open(info_refs_path, 'w') as f:
- f.write('%s\trefs/heads/master\n' % b2a_hex(commit).decode('ascii'))
+ f.write('%s\trefs/heads/master\n' % b2a_hex(str(commit)).decode('ascii'))
- return b2a_hex(blob_oid).decode('ascii')
+ return b2a_hex(str(blob_oid)).decode('ascii')
def _insert_node(self, node_oid, path, root_oid):
@@ -101,7 +101,7 @@ class Fit:
builder = last_dir[1]
pre = last_dir[0]
- builder.insert(filename, node_oid, 0100644)
+ builder.insert(filename, node_oid, GIT_FILEMODE_BLOB)
current_tree_oid = builder.write()
# create new nodes bottom-up for our node
@@ -109,32 +109,26 @@ class Fit:
pre = new_path.pop(0)
for entry in reversed(new_path):
builder = self.repo.TreeBuilder()
- builder.insert(entry, current_tree_oid, 040000)
+ builder.insert(entry, current_tree_oid, GIT_FILEMODE_TREE)
current_tree_oid = builder.write()
# connect existing nodes with created nodes
for name, builder in reversed(existing_builders):
- builder.insert(pre, current_tree_oid, 040000)
+ builder.insert(pre, current_tree_oid, GIT_FILEMODE_TREE)
current_tree_oid = builder.write()
pre = name
return current_tree_oid
- def _get_last_commit(self):
- head = self.repo.lookup_reference('HEAD').resolve()
- return self.repo[head.oid]
-
-
def _list(self, path=None):
""" Lists all entries for a given path """
try:
- commit = self._get_last_commit()
- tree = commit.tree
+ tree = self.repo.head.get_object().tree
if path:
for p in path.split('/'):
- tree = tree[p].to_object()
+ tree = self.repo[tree[p].id]
return [(x.name, x.hex) for x in tree]
diff --git a/requirements.txt b/requirements.txt
index 7906cc2..5a514e1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,8 +1,8 @@
-Flask==0.9
-Flask-WTF==0.8
-Jinja2==2.6
-WTForms==1.0.1
-Werkzeug==0.8.3
-pygit2==0.17.2
-python-magic==0.4.2
-wsgiref==0.1.2
+Flask
+Flask-WTF
+Jinja2
+WTForms
+Werkzeug
+pygit2
+python-magic
+wsgiref
diff --git a/settings.py.sample b/settings.py.sample
index 212c524..7d1f208 100644
--- a/settings.py.sample
+++ b/settings.py.sample
@@ -4,6 +4,7 @@
SECRET_KEY = 'secret_key_to_fill_in'
MAX_CONTENT_LENGTH = 10 * 1024 * 1024
DEBUG = False
+LOG_FILE_PATH = 'app.log'
FORM_START_YEAR = 2000
ALLOWED_EXTENSIONS = ['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'zip', 'gs', 'gz' ]