Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "lib/Core"]
path = lib/Core
url = git@github.com:harlo/UnveillanceCore.git
url = https://github.com/unveillance/UnveillanceCore
78 changes: 42 additions & 36 deletions Models/uv_annex_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,33 @@ def get_new_hash(self, file):
return new_hash

def uploadToAnnex(self, netcat_stub):
use_git_annex = False
this_dir = os.getcwd()
os.chdir(ANNEX_DIR)

if type(netcat_stub['file']) in [str, unicode]:
if GIT_ANNEX is None:
if GIT_ANNEX is not None:
use_git_annex = True
if DEBUG:
print "GIT ANNEX NOT ATTACHED TO INSTANCE."

return None

with settings(warn_only=True):
# has this stub been uploaded?
is_absorbed = local("%s metadata \"%s\" --json --get=uv_uploaded" % (
GIT_ANNEX, netcat_stub['save_as']), capture=True)

if DEBUG: print "%s absorbed? (uv_uploaded = %s type = %s)" % (
netcat_stub['save_as'], is_absorbed, type(is_absorbed))

if is_absorbed == "" or "False":
is_absorbed = False
elif is_absorbed == "True":
is_absorbed = True
else:
is_absorbed = False
print "GIT ANNEX ATTACHED TO INSTANCE."

if use_git_annex:
with settings(warn_only=True):
# has this stub been uploaded?
is_absorbed = local("%s metadata \"%s\" --json --get=uv_uploaded" % (
GIT_ANNEX, netcat_stub['save_as']), capture=True)

if DEBUG: print "%s absorbed? (uv_uploaded = %s type = %s)" % (
netcat_stub['save_as'], is_absorbed, type(is_absorbed))

if is_absorbed == "" or "False":
is_absorbed = False
elif is_absorbed == "True":
is_absorbed = True
else:
is_absorbed = False
else:
is_absorbed = False
else:
is_absorbed = False

Expand Down Expand Up @@ -162,7 +165,7 @@ def uploadToAnnex(self, netcat_stub):
with settings(warn_only=True):
local("mv \"%s\" %s" % (netcat_stub['file'], new_file))

if GIT_ANNEX is not None:
if use_git_annex:
local("%s metadata %s --json --set=uv_file_alias=\"%s\"" % (GIT_ANNEX, new_file, netcat_stub['save_as']))

netcat_stub['file'] = new_file
Expand All @@ -174,7 +177,7 @@ def uploadToAnnex(self, netcat_stub):
# look up to see if this file is already in the annex

with settings(warn_only=True):
if type(netcat_stub['file']) in [str, unicode] and GIT_ANNEX is not None:
if type(netcat_stub['file']) in [str, unicode] and use_git_annex:
local("%s add %s" % (GIT_ANNEX, netcat_stub['save_as']))

p = UnveillanceFabricProcess(netcat, netcat_stub)
Expand All @@ -195,7 +198,7 @@ def uploadToAnnex(self, netcat_stub):
print "ERROR:"
print p.error

if type(netcat_stub['file']) in [str, unicode] and GIT_ANNEX is not None:
if type(netcat_stub['file']) in [str, unicode] and use_git_annex:
local("%s metadata \"%s\" --json --set=uv_uploaded=%s" % (
GIT_ANNEX, netcat_stub['save_as'], str(success_tag)))

Expand All @@ -205,11 +208,13 @@ def uploadToAnnex(self, netcat_stub):
return { 'uploaded' : success_tag, '_id' : new_hash }

def on_created(self, event):
if GIT_ANNEX is None:
use_git_annex = False

if GIT_ANNEX is not None:
if DEBUG:
print "GIT ANNEX NOT ATTACHED TO INSTANCE."
print "GIT ANNEX ATTACHED TO INSTANCE."

return
use_git_annex = True

if event.event_type != "created":
return
Expand All @@ -230,19 +235,20 @@ def on_created(self, event):
filename = event.src_path.split("/")[-1]
never_upload = False

with settings(warn_only=True):
# has this stub been uploaded?
never_upload = local("%s metadata \"%s\" --json --get=uv_never_upload" % (
GIT_ANNEX, filename), capture=True)
if use_git_annex:
with settings(warn_only=True):
# has this stub been uploaded?
never_upload = local("%s metadata \"%s\" --json --get=uv_never_upload" % (
GIT_ANNEX, filename), capture=True)

if DEBUG:
print "%s valid? (uv_never_upload = %s type = %s)" % ( \
filename, never_upload, type(never_upload))
if DEBUG:
print "%s valid? (uv_never_upload = %s type = %s)" % ( \
filename, never_upload, type(never_upload))

if never_upload == "True":
never_upload = True
elif never_upload == "":
never_upload = False
if never_upload == "True":
never_upload = True
elif never_upload == "":
never_upload = False

print "NEVER UPLOAD? %s" % never_upload
if never_upload:
Expand Down
2 changes: 1 addition & 1 deletion lib/Core
Submodule Core updated 3 files
+4 −3 Models/uv_object.py
+1 −1 Utils/funcs.py
+4 −1 vars.py
25 changes: 18 additions & 7 deletions unveillance_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self):
self.on_loads_by_status = [[] for i in range(4)]
self.restricted_routes_by_status = [[] for i in range(4)]
self.restricted_mime_types_by_status = [[] for i in range(4)]
self.restrict_source_files = {}
self.on_loads = {}
self.get_page_load_extras = {}

Expand Down Expand Up @@ -142,19 +143,28 @@ def get(self, uri):
class FileHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(self, file):
if 'restrict' in self.application.restrict_source_files.keys():

if 'exempt' not in self.application.restrict_source_files.keys() or \
file not in self.application.restrict_source_files['exempt']:

srx = r'^/files/\.data/.*'
if not re.match(srx, self.request.uri):
if self.application.do_get_status(self) in self.application.restrict_source_files['restrict']:
res = Result()
res.result = 403

self.set_status(res.result)
self.finish(res.emit())
return

url = "%s%s" % (buildServerURL(), self.request.uri)
if DEBUG:
print url

r = requests.get(url, verify=False)

self.set_header("Content-Type", r.headers['content-type'])

'''
self.set_header("Content-Disposition",
'attachment; filename="%s"' % self.request.uri.split('/')[-1])
'''

self.finish(r.content)

class TaskHandler(tornado.web.RequestHandler):
Expand Down Expand Up @@ -205,7 +215,8 @@ def get(self, route):

if hasattr(self.application, "WEB_TITLE"):
web_title = self.application.WEB_TITLE
else: web_title = WEB_TITLE
else:
web_title = WEB_TITLE

if route is None:
if hasattr(self.application, "INDEX_HEADER"):
Expand Down
4 changes: 3 additions & 1 deletion vars.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from lib.Core.vars import *
import os
from collections import namedtuple
from lib.Core.vars import *

PostBatchRequestStub = namedtuple("PostBatchRequestStub", "files uri")
class PostBatchStub(object):
Expand All @@ -11,6 +12,7 @@ def __init__(self, files, uri):

FILE_NON_OVERWRITES = []
IMPORTER_SOURCES = ["file_added"]
APP_DIR = os.path.join(os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, os.pardir)), "app")

USER_CREDENTIAL_PACK = {
"username" : "",
Expand Down
51 changes: 51 additions & 0 deletions web/css/reset.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*from http://meyerweb.com/eric/thoughts/2008/01/15/resetting-again/ */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td, hr {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
font-weight:normal;
}
strong, b {
font-weight:bold;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}

/* remember to define focus styles! */
:focus {
outline: 0;
}

/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}

/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
3 changes: 2 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
<script type="text/javascript" src="/web/js/lib/crossfilter.min.js"></script>
<script type="text/javascript" src="/web/js/conf.js"></script>
<script type="text/javascript" src="/web/js/unveillance.js"></script>
${ on_loader }
<link rel="stylesheet" type="text/css" href="/web/css/reset.css" />
<link rel="stylesheet" type="text/css" href="/web/css/unveillance.css" />
<link rel="stylesheet" type="text/css" href="/web/css/type.css" />
<link rel="stylesheet" type="text/css" href="/web/css/viz.css" />
${ on_loader }
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

Expand Down
3 changes: 2 additions & 1 deletion web/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
<script type="text/javascript" src="/web/js/unveillance.js"></script>
<script type="text/javascript" src="/web/js/lib/jszip.min.js"></script>
<script type="text/javascript" src="/web/js/conf.js"></script>
${ on_loader }
<link rel="stylesheet" type="text/css" href="/web/css/reset.css" />
<link rel="stylesheet" type="text/css" href="/web/css/unveillance.css" />
<link rel="stylesheet" type="text/css" href="/web/css/type.css" />
<link rel="stylesheet" type="text/css" href="/web/css/viz.css" />
${ on_loader }
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

Expand Down