Skip to content

Commit f1d3926

Browse files
committed
Init
0 parents  commit f1d3926

File tree

15 files changed

+482
-0
lines changed

15 files changed

+482
-0
lines changed

.circleci/config.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
version: 2.1
3+
jobs:
4+
test:
5+
docker:
6+
- image: girder/girder_test:latest
7+
- image: circleci/mongo:4.0-ram
8+
command: ["mongod", "--storageEngine", "ephemeralForTest", "--dbpath", "/dev/shm/mongo"]
9+
10+
steps:
11+
- checkout
12+
- run:
13+
name: Run server tests
14+
command: tox
15+
- run:
16+
name: Run web tests
17+
command: |
18+
npm install
19+
npm run lint
20+
working_directory: import_tracker/web_client
21+
22+
workflows:
23+
version: 2
24+
ci:
25+
jobs:
26+
- test
27+
nightly:
28+
triggers:
29+
- schedule:
30+
cron: "0 0 * * *"
31+
filters:
32+
branches:
33+
only:
34+
- master
35+
jobs:
36+
- test

.editorconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
charset = utf-8
9+
10+
[*.py]
11+
indent_size = 4
12+
max_line_length = 100
13+
14+
[*.js]
15+
indent_size = 4
16+
17+
[*.json]
18+
indent_size = 4
19+
20+
[*.pug]
21+
indent_size = 2
22+
23+
[*.styl]
24+
indent_size = 2
25+
26+
[*.yml]
27+
indent_size = 2

.flake8

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[flake8]
2+
# Recommend matching the black line length (default 88),
3+
# rather than using the flake8 default of 79:
4+
max-line-length = 88
5+
extend-ignore =
6+
# See https://github.com/PyCQA/pycodestyle/issues/373
7+
E203,

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
parts/
19+
sdist/
20+
var/
21+
wheels/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
26+
# Installer logs
27+
pip-log.txt
28+
pip-delete-this-directory.txt
29+
30+
# Unit test / coverage reports
31+
htmlcov/
32+
.tox/
33+
.coverage
34+
.coverage.*
35+
.cache
36+
coverage.xml
37+
*.cover
38+
.hypothesis/
39+
.pytest_cache/
40+
41+
# pyenv
42+
.python-version
43+
44+
# dotenv
45+
.env
46+
47+
# virtualenv
48+
.venv
49+
venv/
50+
ENV/

LICENSE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Apache Software License 2.0
2+
3+
Copyright (c) 2022, Kitware, Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.

MANIFEST.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
include LICENSE
2+
include README.rst
3+
include setup.py
4+
5+
graft import_tracker
6+
graft docs
7+
prune test
8+
global-exclude *.py[co] *.cmake __pycache__ node_modules

README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
==============
2+
import_tracker
3+
==============
4+
5+
A Girder plu
6+
7+
Features
8+
--------
9+
10+
* TODO

import_tracker/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from girder import plugin, events
2+
from girder.utility.model_importer import ModelImporter
3+
4+
from import_tracker.models import AssetstoreImport
5+
6+
7+
class GirderPlugin(plugin.GirderPlugin):
8+
DISPLAY_NAME = "import_tracker"
9+
CLIENT_SOURCE_PATH = "web_client"
10+
11+
def load(self, info):
12+
ModelImporter.registerModel("image", AssetstoreImport, "import_tracker")
13+
events.bind(
14+
"rest.post.assetstore/:id/import.before",
15+
"create_assetstore_import",
16+
AssetstoreImport().createAssetstoreImport,
17+
)
18+
events.bind(
19+
"filesystem_assetstore_imported",
20+
"finish_assetstore_import",
21+
AssetstoreImport().finishAssetstoreImport,
22+
)

import_tracker/models.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from bson.objectid import ObjectId
2+
from datetime import datetime
3+
from girder.events import Event
4+
from girder.models.model_base import Model
5+
from girder.exceptions import ValidationException
6+
7+
8+
class AssetstoreImport(Model):
9+
"""A model that tracks assetstore import events."""
10+
11+
def initialize(self):
12+
self.name = "assetstoreImport"
13+
14+
def validate(self, doc):
15+
# fields = {"name", "started", "completed", "assetstoreId", "params"}
16+
fields = {"name", "started", "assetstoreId", "params"}
17+
missing_keys = doc.keys() - fields
18+
if missing_keys:
19+
raise ValidationException("Fields missing.", ",".join(missing_keys))
20+
21+
return doc
22+
23+
def createAssetstoreImport(self, event: Event):
24+
now = datetime.utcnow()
25+
return self.save(
26+
{
27+
"name": now.isoformat(),
28+
"started": now,
29+
# "completed": None,
30+
"assetstoreId": ObjectId(event.info["id"]),
31+
"params": event.info["params"],
32+
}
33+
)
34+
35+
def finishAssetstoreImport(self, event: Event):
36+
pass

import_tracker/web_client/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Loaded import_tracker!');

0 commit comments

Comments
 (0)