mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Remove dependency on simplejson; convert everything over to using the json module in the python standard library.
This commit is contained in:
+9
-11
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
@@ -10,9 +11,6 @@ sys.path = new_path
|
||||
from galaxy import eggs
|
||||
import pkg_resources
|
||||
|
||||
pkg_resources.require( "simplejson" )
|
||||
import simplejson
|
||||
|
||||
pkg_resources.require( "pycrypto" )
|
||||
from Crypto.Cipher import Blowfish
|
||||
from Crypto.Util.randpool import RandomPool
|
||||
@@ -35,30 +33,30 @@ def get( api_key, url ):
|
||||
# Do the actual GET.
|
||||
url = make_url( api_key, url )
|
||||
try:
|
||||
return simplejson.loads( urllib2.urlopen( url ).read() )
|
||||
except simplejson.decoder.JSONDecodeError, e:
|
||||
return json.loads( urllib2.urlopen( url ).read() )
|
||||
except json.decoder.JSONDecodeError, e:
|
||||
print "URL did not return JSON data"
|
||||
sys.exit(1)
|
||||
|
||||
def post( api_key, url, data ):
|
||||
# Do the actual POST.
|
||||
url = make_url( api_key, url )
|
||||
req = urllib2.Request( url, headers = { 'Content-Type': 'application/json' }, data = simplejson.dumps( data ) )
|
||||
return simplejson.loads( urllib2.urlopen( req ).read() )
|
||||
req = urllib2.Request( url, headers = { 'Content-Type': 'application/json' }, data = json.dumps( data ) )
|
||||
return json.loads( urllib2.urlopen( req ).read() )
|
||||
|
||||
def put( api_key, url, data ):
|
||||
# Do the actual PUT
|
||||
url = make_url( api_key, url )
|
||||
req = urllib2.Request( url, headers = { 'Content-Type': 'application/json' }, data = simplejson.dumps( data ))
|
||||
req = urllib2.Request( url, headers = { 'Content-Type': 'application/json' }, data = json.dumps( data ))
|
||||
req.get_method = lambda: 'PUT'
|
||||
return simplejson.loads( urllib2.urlopen( req ).read() )
|
||||
return json.loads( urllib2.urlopen( req ).read() )
|
||||
|
||||
def __del( api_key, url, data ):
|
||||
# Do the actual DELETE
|
||||
url = make_url( api_key, url )
|
||||
req = urllib2.Request( url, headers = { 'Content-Type': 'application/json' }, data = simplejson.dumps( data ))
|
||||
req = urllib2.Request( url, headers = { 'Content-Type': 'application/json' }, data = json.dumps( data ))
|
||||
req.get_method = lambda: 'DELETE'
|
||||
return simplejson.loads( urllib2.urlopen( req ).read() )
|
||||
return json.loads( urllib2.urlopen( req ).read() )
|
||||
|
||||
|
||||
def display( api_key, url, return_formatted=True ):
|
||||
|
||||
@@ -11,11 +11,11 @@ sys.path.insert( 0, os.path.dirname( __file__ ) )
|
||||
from common import submit
|
||||
|
||||
### Rpark edit ###
|
||||
import simplejson
|
||||
import json
|
||||
|
||||
def openWorkflow(in_file):
|
||||
with open(in_file) as f:
|
||||
temp_data = simplejson.load(f)
|
||||
temp_data = json.load(f)
|
||||
return temp_data;
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
Terminates a DRMAA job if given a job id and (appropriate) user id.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import errno
|
||||
import json
|
||||
import os
|
||||
import pwd
|
||||
import sys
|
||||
#import drmaa
|
||||
new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
@@ -15,8 +16,6 @@ sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
import pkg_resources
|
||||
pkg_resources.require("simplejson")
|
||||
import simplejson as json
|
||||
pkg_resources.require("drmaa")
|
||||
import drmaa
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import os
|
||||
import sys
|
||||
import errno
|
||||
import pwd
|
||||
import json
|
||||
|
||||
#import simplejson as json
|
||||
#import drmaa
|
||||
new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
@@ -19,8 +19,6 @@ sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
import pkg_resources
|
||||
pkg_resources.require("simplejson")
|
||||
import simplejson as json
|
||||
pkg_resources.require("drmaa")
|
||||
import drmaa
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
import errno
|
||||
import json
|
||||
import os
|
||||
import pwd
|
||||
import sys
|
||||
#import drmaa
|
||||
|
||||
new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
import pkg_resources
|
||||
pkg_resources.require("simplejson")
|
||||
import simplejson as json
|
||||
pkg_resources.require("drmaa")
|
||||
import drmaa
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@ Used by jobs that split large files into pieces to be processed concurrently
|
||||
on a gid in a scatter-gather mode. This does part of the scatter.
|
||||
|
||||
"""
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
logging.basicConfig()
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
@@ -16,11 +17,6 @@ new_path = [ os.path.join( os.getcwd(), "lib" ) ]
|
||||
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
import pkg_resources
|
||||
pkg_resources.require("simplejson")
|
||||
import simplejson
|
||||
|
||||
# This junk is here to prevent loading errors
|
||||
import galaxy.model.mapping #need to load this before we unpickle, in order to setup properties assigned by the mappers
|
||||
galaxy.model.Job() #this looks REAL stupid, but it is REQUIRED in order for SA to insert parameters into the classes defined by the mappers --> it appears that instantiating ANY mapper'ed class would suffice here
|
||||
@@ -33,7 +29,7 @@ def __main__():
|
||||
if not os.path.isfile(file_path):
|
||||
#Nothing to do - some splitters don't write a JSON file
|
||||
sys.exit(0)
|
||||
data = simplejson.load(open(file_path, 'r'))
|
||||
data = json.load(open(file_path, 'r'))
|
||||
try:
|
||||
class_name_parts = data['class_name'].split('.')
|
||||
module_name = '.'.join(class_name_parts[:-1])
|
||||
|
||||
@@ -13,12 +13,21 @@ python data_transfer.py <config_file>
|
||||
|
||||
"""
|
||||
import ConfigParser
|
||||
import sys, os, time, traceback
|
||||
import cookielib
|
||||
import datetime
|
||||
import logging
|
||||
import optparse
|
||||
import urllib,urllib2, cookielib, shutil
|
||||
import logging, time, datetime
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import time
|
||||
import traceback
|
||||
import urllib
|
||||
import urllib2
|
||||
import xml.dom.minidom
|
||||
|
||||
|
||||
from xml_helper import get_value, get_value_index
|
||||
|
||||
log = logging.getLogger( "datatx_" + str( os.getpid() ) )
|
||||
@@ -39,14 +48,11 @@ new_path.extend( sys.path[1:] ) # remove scripts/ from the path
|
||||
sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
from galaxy.util.json import from_json_string, to_json_string
|
||||
from galaxy.model import SampleDataset
|
||||
from galaxy.web.api.samples import SamplesAPIController
|
||||
import pkg_resources
|
||||
pkg_resources.require( "pexpect" )
|
||||
import pexpect
|
||||
pkg_resources.require( "simplejson" )
|
||||
import simplejson
|
||||
|
||||
log.debug(str(dir(api)))
|
||||
|
||||
|
||||
@@ -10,9 +10,11 @@ import logging
|
||||
logging.basicConfig()
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
import cPickle
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import cPickle
|
||||
|
||||
# ensure supported version
|
||||
from check_python import check_python
|
||||
try:
|
||||
@@ -26,8 +28,6 @@ sys.path = new_path
|
||||
|
||||
from galaxy import eggs
|
||||
import pkg_resources
|
||||
pkg_resources.require("simplejson")
|
||||
import simplejson
|
||||
import galaxy.model.mapping # need to load this before we unpickle, in order to setup properties assigned by the mappers
|
||||
galaxy.model.Job() # this looks REAL stupid, but it is REQUIRED in order for SA to insert parameters into the classes defined by the mappers --> it appears that instantiating ANY mapper'ed class would suffice here
|
||||
from galaxy.util import stringify_dictionary_keys
|
||||
@@ -107,17 +107,17 @@ def __main__():
|
||||
dataset.extension = ext_override[ dataset.dataset.id ]
|
||||
# Metadata FileParameter types may not be writable on a cluster node, and are therefore temporarily substituted with MetadataTempFiles
|
||||
if override_metadata:
|
||||
override_metadata = simplejson.load( open( override_metadata ) )
|
||||
override_metadata = json.load( open( override_metadata ) )
|
||||
for metadata_name, metadata_file_override in override_metadata:
|
||||
if galaxy.datatypes.metadata.MetadataTempFile.is_JSONified_value( metadata_file_override ):
|
||||
metadata_file_override = galaxy.datatypes.metadata.MetadataTempFile.from_JSON( metadata_file_override )
|
||||
setattr( dataset.metadata, metadata_name, metadata_file_override )
|
||||
kwds = stringify_dictionary_keys( simplejson.load( open( filename_kwds ) ) ) # load kwds; need to ensure our keywords are not unicode
|
||||
kwds = stringify_dictionary_keys( json.load( open( filename_kwds ) ) ) # load kwds; need to ensure our keywords are not unicode
|
||||
dataset.datatype.set_meta( dataset, **kwds )
|
||||
dataset.metadata.to_JSON_dict( filename_out ) # write out results of set_meta
|
||||
simplejson.dump( ( True, 'Metadata has been set successfully' ), open( filename_results_code, 'wb+' ) ) # setting metadata has succeeded
|
||||
json.dump( ( True, 'Metadata has been set successfully' ), open( filename_results_code, 'wb+' ) ) # setting metadata has succeeded
|
||||
except Exception, e:
|
||||
simplejson.dump( ( False, str( e ) ), open( filename_results_code, 'wb+' ) ) # setting metadata has failed somehow
|
||||
json.dump( ( False, str( e ) ), open( filename_results_code, 'wb+' ) ) # setting metadata has failed somehow
|
||||
clear_mappers()
|
||||
# Shut down any additional threads that might have been created via the ObjectStore
|
||||
object_store.shutdown()
|
||||
|
||||
Reference in New Issue
Block a user