Skip to content

Commit

Permalink
Merge pull request ome#3274 from sbesson/flake8_toplevel
Browse files Browse the repository at this point in the history
Move setup.cfg to the top-level directory
  • Loading branch information
sbesson committed Dec 15, 2014
2 parents fc131c4 + e089b68 commit 3c21f41
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 637 deletions.
46 changes: 25 additions & 21 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@
# General build scripts.

import os
import re
import sys
import time
import subprocess

BUILD_PY = "-Dbuild.py=true"


def popen(args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE):
copy = os.environ.copy()
return subprocess.Popen(args,
env=copy,
stdin=stdin,
stdout=stdout,
stderr=stderr)
copy = os.environ.copy()
return subprocess.Popen(args,
env=copy,
stdin=stdin,
stdout=stdout,
stderr=stderr)


def execute(args):
Expand All @@ -43,48 +41,54 @@ def notification(msg, prio):
return

try:
p = popen(["growlnotify","-t","OMERO Build Status","-p",str(prio)], stdin=subprocess.PIPE)
p = popen(["growlnotify", "-t", "OMERO Build Status", "-p",
str(prio)], stdin=subprocess.PIPE)
p.communicate(msg)
rc = p.wait()
if rc != 0:
pass # growl didn't work
pass # growl didn't work
except OSError:
pass # No growlnotify found, may want to use another tool
pass # No growlnotify found, may want to use another tool


def java_omero(args):
command = [ find_java() ]
p = os.path.join( os.path.curdir, "lib", "log4j-build.xml")
command = [find_java()]
p = os.path.join(os.path.curdir, "lib", "log4j-build.xml")
command.append("-Dlog4j.configuration=%s" % p)
command.append(BUILD_PY)
command.extend( calculate_memory_args() )
command.extend(calculate_memory_args())
command.extend(["omero"])
if isinstance(args,str):
if isinstance(args, str):
command.append(args)
else:
command.extend(args)
execute(command)


def find_java():
return "java"


def calculate_memory_args():
return "-Xmx600M -XX:MaxPermSize=256m".split(" ")


def handle_tools(args):
_ = os.path.sep.join
additions = []
mappings = {
"-top": _(["build.xml"]),
"-cpp": _(["components","tools","OmeroCpp","build.xml"]),
"-fs": _(["components","tools","OmeroFS","build.xml"]),
"-java": _(["components","tools","OmeroJava","build.xml"]),
"-py": _(["components","tools","OmeroPy","build.xml"]),
"-web": _(["components","tools","OmeroWeb","build.xml"]),
"-cpp": _(["components", "tools", "OmeroCpp", "build.xml"]),
"-fs": _(["components", "tools", "OmeroFS", "build.xml"]),
"-java": _(["components", "tools", "OmeroJava", "build.xml"]),
"-py": _(["components", "tools", "OmeroPy", "build.xml"]),
"-web": _(["components", "tools", "OmeroWeb", "build.xml"]),
}
while len(args) > 0 and args[0] in mappings.keys()+["-perf"]:
if args[0] == "-perf":
args.pop(0)
A = "-listener net.sf.antcontrib.perf.AntPerformanceListener".split()
A = ["-listener",
"net.sf.antcontrib.perf.AntPerformanceListener"]
additions.extend(A)
elif args[0] in mappings.keys():
F = mappings[args.pop(0)]
Expand Down
83 changes: 47 additions & 36 deletions components/blitz/blitz_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,47 @@
# Use is subject to license terms supplied in LICENSE.txt
#

import sys, os, glob, subprocess
import optparse
from SCons.Script.SConscript import *
from SCons.Script import AddOption, GetOption
from SCons.SConf import *
from SCons.Variables import *
import os
import glob
import subprocess
from SCons.Script.SConscript import SConsEnvironment

#
# Global Directories
#
cwd = os.path.abspath( os.path.dirname( __file__ ) )
top = os.path.abspath( os.path.join( cwd, os.path.pardir, os.path.pardir ) )
blitz_resources = os.path.abspath( os.path.join( top, "components", "blitz", "resources") )
blitz_generated = os.path.abspath( os.path.join( top, "components", "blitz", "generated") )
tools_include = os.path.abspath( os.path.join( top, "components", "tools", "target", "include" ) )
tools_library = os.path.abspath( os.path.join( top, "components", "tools", "target", "lib" ) )
header = os.path.join( blitz_resources, "header.txt" )
cwd = os.path.abspath(os.path.dirname(__file__))
top = os.path.abspath(os.path.join(cwd, os.path.pardir, os.path.pardir))
blitz_resources = os.path.abspath(
os.path.join(top, "components", "blitz", "resources"))
blitz_generated = os.path.abspath(
os.path.join(top, "components", "blitz", "generated"))
tools_include = os.path.abspath(
os.path.join(top, "components", "tools", "target", "include"))
tools_library = os.path.abspath(
os.path.join(top, "components", "tools", "target", "lib"))
header = os.path.join(blitz_resources, "header.txt")

# Relative
resources = os.path.abspath("resources")
generated = os.path.abspath("generated")

# Support ICE_HOME
if os.environ.has_key("ICE_HOME"):
ice_home = os.path.abspath( os.environ["ICE_HOME"] )
if "ICE_HOME" in os.environ:
ice_home = os.path.abspath(os.environ["ICE_HOME"])
print "Using env[ICE_HOME] = %s" % (ice_home)
else:
ice_home = None
if os.environ.has_key("SLICEPATH"):
slicepath = os.path.abspath( os.environ["SLICEPATH"] )
if "SLICEPATH" in os.environ:
slicepath = os.path.abspath(os.environ["SLICEPATH"])
print "Using env[SLICEPATH] = %s" % (slicepath)
else:
slicepath = None
if os.environ.has_key("SLICE2JAVA"):
if "SLICE2JAVA" in os.environ:
slice2java = os.environ["SLICE2JAVA"]
print "Using env[SLICE2JAVA] = %s" % (slice2java)
else:
slice2java = None
if os.environ.has_key("SLICE2PY"):
if "SLICE2PY" in os.environ:
slice2py = os.environ["SLICE2PY"]
print "Using env[SLICE2PY] = %s" % (slice2py)
else:
Expand All @@ -68,17 +70,21 @@ def jdep(DEPMAP, target):
# Helpers
#

def common(dir = generated):

def common(dir=generated):
"""
Necessary since output for C++ does not include directories.
"""
return ["-I%s" % generated, "-I%s" % resources, "-I%s" % slicepath, "--output-dir=%s" % dir]
return ["-I%s" % generated, "-I%s" % resources, "-I%s" % slicepath,
"--output-dir=%s" % dir]


def names(dir, ice):
basename = os.path.basename(ice)[:-4]
filename = '%s/%s' % (dir, basename)
return (basename, filename)


def basenames(where, dir):
for ice in glob.glob("%s/%s/*.ice" % (where, dir)):
yield names(dir, ice)
Expand All @@ -87,37 +93,40 @@ def basenames(where, dir):
# Define calls to slice2java and slice2py
#


def make_slice(command):
def slice(target, source, env):
args = command+[str(source[0].get_abspath())]
rv = subprocess.call(args)
if rv != 0:
raise Exception("%s returned %s" % (str(args), str(rv)) )
raise Exception("%s returned %s" % (str(args), str(rv)))
return slice


def slice_java(env, where, dir):
command = [slice2java, "--tie"] + common()
command = [slice2java, "--tie"] + common()
actions = []
for basename, filename in basenames(where, dir):
c = env.Command(
jdep(env["DEPMAP"], filename + '.java' ), # target
jdep(env["DEPMAP"], filename + '.java'), # target
filename + '.ice', # source
make_slice(command), # command
chdir = where ) # dir
actions.append( c )
chdir=where) # dir
actions.append(c)
return actions


def slice_py(env, where, dir):
prefix = dir.replace("/","_") + "_"
command = [slice2py, "--prefix", "%s" % prefix ] + common()
prefix = dir.replace("/", "_") + "_"
command = [slice2py, "--prefix", "%s" % prefix] + common()
actions = []
for basename, filename in basenames(where, dir):
c = env.Command(
[prefix + basename + '_ice.py' ], # target
filename + '.ice', # source
[prefix + basename + '_ice.py'], # target
filename + '.ice', # source
make_slice(command), # command
chdir = where ) # dir
actions.append( c )
chdir=where) # dir
actions.append(c)
return actions

#
Expand Down Expand Up @@ -149,8 +158,10 @@ def __init__(self, **kwargs):
except KeyError:
self.omero_quiet = False

# Very odd error: using ENV = os.environ, rather than ENV = dict(os.environ)
# causes *sub*processes to receive a fresh environment with registry values
# for PATH, LIB, etc. *pre*pended to the variables.
SConsEnvironment.__init__(self, ENV = dict(os.environ), tools=tools, **kwargs)
# Very odd error: using ENV = os.environ, rather than
# ENV = dict(os.environ) causes *sub*processes to receive a fresh
# environment with registry values for PATH, LIB, etc. *pre*pended to
# the variables.
SConsEnvironment.__init__(self, ENV=dict(os.environ), tools=tools,
**kwargs)
self.Decider('MD5-timestamp')
49 changes: 31 additions & 18 deletions components/server/src/ome/services/sharing/make_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
See LICENSE for details.
"""
import sys, os, subprocess, time, glob
import sys
import os
import subprocess
import time
import glob


def readlink(file=sys.argv[0]):
import stat
Expand All @@ -36,48 +41,56 @@ def readlink(file=sys.argv[0]):
rep = os.path.join(top, "lib", "repository")
rep = os.path.normpath(rep)


def call(cmd, cwd="."):
rc = subprocess.call(cmd, shell=True, cwd=cwd)
if rc != 0:
print "Halting..."
sys.exit(rc)


def clean(dir=dat):
if os.path.exists(dat):
print "Removing %s. Cancel now if necessary. Waiting 5 seconds." % dat
print "Removing %s. Cancel now if necessary. Waiting 5 seconds." \
% dat
time.sleep(5)
ls = os.listdir(dat)
for file in ls:
print "Removing %s" % file
os.remove(os.path.join(dat,file))
os.remove(os.path.join(dat, file))
os.rmdir(dat)


def slice(dir=dat):
os.mkdir(dat)
README = open(os.path.join(dat,"README.txt"),"w")
README = open(os.path.join(dat, "README.txt"), "w")
README.write("""
THE FILES IN THIS DIRECTORY ARE GENERATE
AND WILL BE AUTOMATICALLY DELETED
""")
README.flush()
README.close()
call("""slice2freezej --dict ome.services.sharing.data.ShareMap,long,ome::services::sharing::data::ShareData \
--dict-index ome.services.sharing.data.ShareMap,id \
--dict-index ome.services.sharing.data.ShareMap,owner \
--output-dir %s \
Share.ice""" % src)
call("""slice2freezej --dict ome.services.sharing.data.ShareItems,long,ome::services::sharing::data::ShareItem \
--dict-index ome.services.sharing.data.ShareItems,type \
--dict-index ome.services.sharing.data.ShareItems,share \
--output-dir %s \
Share.ice""" % src)
call("""slice2freezej \
--dict ome.services.sharing.data.ShareMap,\
long,ome::services::sharing::data::ShareData \
--dict-index ome.services.sharing.data.ShareMap,id \
--dict-index ome.services.sharing.data.ShareMap,owner \
--output-dir %s Share.ice""" % src)
call("""slice2freezej \
--dict ome.services.sharing.data.ShareItems,\
long,ome::services::sharing::data::ShareItem \
--dict-index ome.services.sharing.data.ShareItems,type \
--dict-index ome.services.sharing.data.ShareItems,share \
--output-dir %s Share.ice""" % src)
call("""slice2java --output-dir %s Share.ice""" % src)


def compile(dir=dat):
proc = subprocess.Popen("slice2java --version", \
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
proc = subprocess.Popen(
"slice2java --version",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
version = proc.communicate()[1].strip()
pat = "%s/ice*%s.jar" % (rep, version)
cp = ":".join(glob.glob(pat))
Expand Down
6 changes: 4 additions & 2 deletions components/tests/ui/library/python/ImageCheckLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ def image_should_be_blank(path, expected=True):

if expected:
if not blank:
raise AssertionError("Image %s is not blank. min: %s, max: %s" % (path, minVals, maxVals))
raise AssertionError("Image %s is not blank. min: %s, max: %s"
% (path, minVals, maxVals))
else:
if blank:
raise AssertionError("Image %s is blank. min: %s, max: %s" % (path, minVals, maxVals))
raise AssertionError("Image %s is blank. min: %s, max: %s"
% (path, minVals, maxVals))


def image_should_not_be_blank(path):
Expand Down
3 changes: 0 additions & 3 deletions components/tools/setup.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion components/tools/travis-build
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ build_java()

build_python()
{
flake8 -v components/tools
flake8 -v .
./build.py build-default
./build.py -py test -Dtest.with.fail=true -DMARK="not broken"
./build.py -fs test -Dtest.with.fail=true -DMARK="not broken"
Expand Down
Loading

0 comments on commit 3c21f41

Please sign in to comment.