Permalink
Browse files

added submodule, and updated upload and fix code

  • Loading branch information...
1 parent 38be29c commit ee7d0b423484f1e746456a2d5a4b79c0ffc2d768 Walt Grata committed Jun 2, 2011
Showing with 53 additions and 18 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 utils/LRSignature
  3. +20 −3 utils/fix.py
  4. +1 −2 utils/samples/php/signing.php
  5. +2 −2 utils/testconfig.ini
  6. +26 −11 utils/upload.py
View
@@ -0,0 +1,3 @@
+[submodule "utils/LRSignature"]
+ path = utils/LRSignature
+ url = git://github.com/jimklo/LRSignature.git
Submodule LRSignature added at afcb35
View
@@ -1,17 +1,33 @@
#!/usr/bin/python
import os, json
import ConfigParser
-
_config = ConfigParser.ConfigParser()
_config.read('testconfig.ini')
base_path = _config.get("fix", "root_path")
-
for file in os.listdir(base_path):
changed = False
file_path = os.path.join(base_path, file)
with open(file_path,'r+') as f:
data = json.load(f)
-
+ data['doc_version'] = '0.21.0'
+ if data.has_key('submitter'):
+ changed = True
+ del data['submitter']
+ if data.has_key('submitter_type'):
+ changed = True
+ del data['submitter_type']
+ if data.has_key('identify'):
+ del data['identify']
+ changed = True
+ if not data.has_key('identity'):
+ changed = True
+ identity = {
+ 'submitter_type':'agent',
+ 'submitter':'Learning Registry',
+ 'curator':'European School Net',
+ 'owner':'European School Net',
+ 'signer':''}
+ data['identity'] = identity
if data.has_key('submission_TOS'):
changed = True
del data['submission_TOS']
@@ -20,6 +36,7 @@
data['TOS'] = {
'submission_TOS':'http://www.learningregistry.org/tos/cc0/v0-5/'
}
+
if data.has_key('created_timestamp'):
changed = True
del data['created_timestamp']
@@ -44,8 +44,7 @@ function format_data_to_sign($rawData){
$encoder = new bencoding();
$data = utf8_encode($encoder->encode($rawData));
$hash = hash('SHA256',$data);
- echo $hash, "\n";
- return hash;
+ return $hash;
}
function verify_file($filedata, $signature){
$gpg = new Crypt_GPG();
@@ -1,7 +1,7 @@
[upload]
root_path=/home/wegrata/LearningRegistryData/metadata
-publish_url=http://localhost/publish
-sword_url=http://localhost/sword
+publish_url=http://ec2-50-17-87-122.compute-1.amazonaws.com/publish
+sword_url=http://ec2-50-17-87-122.compute-1.amazonaws.com/sword
[fix]
root_path=/home/wegrata/LearningRegistryData/metadata
View
@@ -1,13 +1,21 @@
#!/usr/bin/python
import urllib2,os,json
import ConfigParser
-from random import choice
+from random import choice
+import argparse
+from LRSignature.sign.Sign import Sign_0_21
+signer = None
+parser = argparse.ArgumentParser(description='Sign files and upload to Learning Registry')
+parser.add_argument('--key', help='PGP Private Key ID')
+parser.add_argument('--key-location', help='Location the PGP Public Key can be downloaded from')
+args = parser.parse_args()
+if args.key is not None and args.key_location is not None:
+ signer = Sign_0_21(privateKeyID=args.key ,publicKeyLocations=[args.key_location])
_config = ConfigParser.ConfigParser()
_config.read('testconfig.ini')
root_path = _config.get("upload", "root_path")
publish_url = _config.get("upload", "publish_url")
publish_urls = ['http://lrdev1.learningregistry.org/publish','http://lrdev2.learningregistry.org/publish','http://lrdev3.learningregistry.org/publish']
-documents=[]
def upload_files(docs):
try:
@@ -20,13 +28,20 @@ def upload_files(docs):
except urllib2.HTTPError as er:
with open('error.html','a') as out:
out.write(er.read())
- print 'error'
-for file in os.listdir(root_path):
- #publish_url = choice(publish_urls)
- file_path = os.path.join(root_path,file)
- with open(file_path,'r+') as f:
- data = json.load(f)
- documents.append(data)
- if len(documents) >= 10:
- upload_files(documents)
+ print 'error'
+def process_files():
documents=[]
+ for file in os.listdir(root_path):
+ file_path = os.path.join(root_path,file)
+ with open(file_path,'r+') as f:
+ data = json.load(f)
+ if signer is not None:
+ data = signer.sign(data)
+ documents.append(data)
+ if len(documents) >= 10:
+ upload_files(documents)
+ documents=[]
+def main():
+ process_files();
+if __name__ == '__main__':
+ main()

0 comments on commit ee7d0b4

Please sign in to comment.