Skip to content

Commit

Permalink
working on more granular updates of the index (not done yet) #89
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Mar 31, 2020
1 parent 3c93bd0 commit 0b4a7b4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clam/clamdispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import signal
import shutil

VERSION = '3.0.10'
VERSION = '3.0.12'

sys.path.append(sys.path[0] + '/..')

Expand Down
40 changes: 40 additions & 0 deletions clam/clamservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,46 @@ def getprojects(user):
json.dump({'totalsize': totalsize, 'projects': projects},f, ensure_ascii=False)
return projects, round(totalsize)

def updateindex(user, project):
totalsize = 0.0
path = settings.ROOT + "projects/" + user
with io.open(os.path.join(path,'.index'),'r',encoding='utf-8') as f:
try:
data = json.load(f)
except ValueError:
printlog("Invalid json in .index")
#delete the entire index
os.unlink(os.path.join(path,'.index'))
return False
f = os.path.join(path, project)
if not os.path.isdir(f):
return False
d = datetime.datetime.fromtimestamp(os.stat(f)[8])
project = os.path.basename(f)
projectsize, filecount = Project.getdiskusage(user,project )
totalsize += projectsize
index = None
for i, projectdata in enumerate(projects):
totalsize += projectdata[2]
if projectdata[0] == project:
index = i
projectdata = ( project , d.strftime("%Y-%m-%d %H:%M:%S"), round(projectsize,2), Project.simplestatus(project,user) )
changed = True
if index is None:
data['projects'].append( projectdata )
elif data["projects"][index] != projectdata:
data["projects"][index] = projectdata
else:
changed = False
if totalsize != data['totalsize']:
data["totalsize"] = totalsize
changed = True
if changed:
with io.open(os.path.join(path,'.index'),'w',encoding='utf-8') as f:
json.dump(data,f, ensure_ascii=False)
return True


def mainentry(credentials = None):
"""This is the main (root) entry point, it can direct to various pages based on configuration and authentication"""

Expand Down
2 changes: 1 addition & 1 deletion clam/common/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import clam.common.util
import clam.common.viewers

VERSION = '3.0.11'
VERSION = '3.0.12'

#dirs for services shipped with CLAM itself
CONFIGDIR = os.path.abspath(os.path.dirname(__file__) + '/../config/')
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@type": "SoftwareSourceCode",
"identifier": "clam",
"name": "CLAM",
"version": "3.0.11",
"version": "3.0.12",
"description": "Quickly turn command-line applications into RESTful webservices with a web-application front-end. You provide a specification of your command line application, its input, output and parameters, and CLAM wraps around your application to form a fully fledged RESTful webservice. ",
"license": "https://spdx.org/licenses/GPL-3.0",
"url": "https://proycon.github.io/clam",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def read(fname):

setup(
name = "CLAM",
version = "3.0.11", #also change in clam.common.data.VERSION and dispatcher.py and codemeta.json
version = "3.0.12", #also change in clam.common.data.VERSION and dispatcher.py and codemeta.json
author = "Maarten van Gompel",
author_email = "proycon@anaproy.nl",
description = ("Turns command-line NLP tools into fully-fledged RESTful webservices with an auto-generated web-interface for human end-users."),
Expand Down

0 comments on commit 0b4a7b4

Please sign in to comment.