Example #1
0
 def getBinFlags (self, user=False):
     """returns: the linker flags to use when linking a binary
     depending on all the packages in the list"""
     preresult = ["-L" + os.path.join (self.m_wa.bin(), "lib",
                                       self.m_wa.arch())]
     result = get_field (self.m_wa.root_conf(), "LDFLAGS").split()
     #result = string.split (get_field (self.m_wa.root_conf(), "LDFLAGS"))
     for var in ["LDFLAGS"]:
         flags = os.getenv (var)
         if flags and flags != "":
             preresult += flags.split()
             #preresult += string.split (flags)
             pass
         pass
     for pkg in self.m_packages:
         preresult += pkg.libflags().split()
         #preresult += string.split (pkg.libflags())
         result = pkg.binflags().split() + result
         #result = string.split (pkg.binflags()) + result
         for preload in pkg.preload():
             result = ["-l" + preload] + result
             pass
         if not pkg.nocc():
             result = ["-l" + pkg.name()] + result
         pass
     if not user:
         result += get_field (self.m_wa.root_conf(), "ROOTLIBS").split()
         #result += string.split (get_field (self.m_wa.root_conf(), "ROOTLIBS"))
     return " ".join (preresult + result)
Example #2
0
def login():
    if request.method == 'GET':
        return render_template('login.html')

    email = utils.get_field(request, 'email', required=True)
    password = utils.get_field(request, 'password', required=True)
    return users.login(email, password, bcrypt)
Example #3
0
 def getLibFlags (self, lib, user=False, external=False):
     """returns: the linker flags to use when linking a library
     depending on all the packages in the list"""
     result = ""
     if not user and not external:
         result = str(result + " " +
                      get_field (self.m_wa.root_conf(), "SOFLAGS")).strip()
         #result = string.strip (result + " " + get_field (self.m_wa.root_conf(), "SOFLAGS"))
         pass
     result = str(result + " " +
                  shell_exec (["root-config", "--ldflags"])).strip()
     #result = string.strip (result + " " + shell_exec (["root-config", "--ldflags"]))
     for var in ["LDFLAGS", "CPPEXFLAGS"]:
         flags = os.getenv (var)
         if flags and flags != "":
             result = str(result + " " + flags).strip()
             pass
         pass
     if not user:
         result += " " + get_field (self.m_wa.root_conf(), "ROOTLIBS")
         pass
     if (not user and not external and
         get_field (self.m_wa.root_conf(), "PLATFORM") == "macosx"):
         result = str(result + " -dynamiclib -undefined dynamic_lookup" +
                      " -install_name @rpath/" +
                      os.path.basename (lib)).strip()
         #result = string.strip (result + " -dynamiclib -undefined dynamic_lookup -install_name @rpath/" + os.path.basename (lib))
         pass
     return result;
Example #4
0
    def root_conf(self):
        """effects: determine the root parameters used for compilation
        returns: the path to the configuration file generated
        failures: incompatible root installation"""
        if not self.m_root_conf:
            file = os.path.join(self.bin(), "root_config_" + self.arch())
            ROOTSYS = os.getenv("ROOTSYS")
            if ROOTSYS == None:
                if os.path.isfile(file):
                    ROOTSYS = get_field(file, "ROOTSYS")
                    if ROOTSYS and ROOTSYS != "":
                        raise RCError("no valid root version found, try setting up root using\n" +
                                      "  source " + ROOTSYS + "/bin/thisroot.sh")
                if os.path.isdir("/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase"):
                    raise RCError("no valid root version found, try setting up root using\n" +
                                  "  export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase\n" +
                                  "  source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh\n" +
                                  "  localSetupROOT")
                if shell_exec(["which", "root-config"], allowFail=True) != "":
                    raise RCError("no valid root version found, try setting up root using\n" +
                                  "  source `root-config --prefix`/bin/thisroot.sh")
                raise RCError("no valid root version found, please set up root")

            if os.path.isfile(file):
                myrootversion = get_field(file, "ROOT_VERSION")
                if not myrootversion:
                    set_field(file, "ROOT_VERSION", self.root_version())
                elif self.root_version() != myrootversion:
                    myrootsys = get_field(file, "ROOTSYS")
                    raise RCError("Root Version: " + self.root_version() + "\n" +
                                  "is not the same as previous version:\n" +
                                  "   " + myrootversion + "\n" +
                                  "either set up the correct root version e.g. via:\n" +
                                  "  source " + myrootsys + "/bin/thisroot.sh\n" +
                                  "or clean out the old object files via:\n" +
                                  "  rc clean")
                self.m_root_conf = file
                return file

            myarch = shell_exec(["root-config", "--etcdir"]) + "/Makefile.arch"
            if not os.path.isfile(myarch):
                myarch = os.getenv("ROOTSYS") + "/share/doc/root/test/Makefile.arch"
            if not os.path.isfile(myarch):
                shell_args = ["find", os.getenv("ROOTSYS") + "/.",
                              "-name", "Makefile.arch"]
                search = shell_exec(shell_args).strip().split("\n")
                if len(search) > 0:
                    myarch = search[0]
            if not os.path.isfile(myarch):
                raise RCError("failed to find Makefile.arch in " + os.getenv("ROOTSYS"))

            with open(file + "-", "w") as f:
                shell_args = ["make", "-f", self.dir() + "/Makefile-print",
                              "MAKEFILE_ARCH=" + myarch]
                rc = shell_exec(shell_args, stdout=f, returnRC=True)
            if rc != 0:
                raise RCError("could not determine compilation parameters")
            os.rename(file + "-", file)
            self.m_root_conf = file
        return self.m_root_conf
Example #5
0
def get_filters():
    if request.method == 'GET':
        return render_template('filters.html')

    lat = utils.get_field(request, 'lat', required=True)
    lng = utils.get_field(request, 'long', required=True)

    return restaurants.get_filters(lat, lng)
Example #6
0
    def __init__(self, RootCoreBin=None, RootCoreDir=None):
        self.m_area = None
        self.m_areaList = None
        self.m_packages = None
        self.m_arch = os.getenv("ROOTCORECONFIG")
        if not self.m_arch:
            self.m_arch = "generic"
            pass
        self.m_root_conf = None
        self.m_pedantic = None

        if RootCoreDir and not os.path.isabs(RootCoreDir):
            RootCoreDir = os.path.join(os.getcwd(), RootCoreDir)
        if RootCoreBin and not os.path.isabs(RootCoreBin):
            RootCoreBin = os.path.join(os.getcwd(), RootCoreBin)

        if RootCoreDir != None:
            self.m_dir = RootCoreDir
            if RootCoreBin != None:
                self.m_bin = RootCoreBin
            else:
                self.m_bin = self.m_dir
            self.m_obj = os.path.join(self.m_bin, "obj")
        elif RootCoreBin != None:
            self.m_bin = RootCoreBin
            self.m_config = self.m_bin + "/rootcore_config"
            self.m_dir = self.expandPath(get_field(self.m_config, "rootcoredir"))
            if not self.m_dir or self.m_dir == "":
                self.m_dir = RootCoreBin
            self.m_obj = self.expandPath(get_field(self.m_config, "rootcoreobj"))
            if not self.m_obj or self.m_obj == "":
                self.m_obj = os.path.join(RootCoreBin, "obj")

            p = os.path
            if (not p.isfile(p.join(self.m_dir, "internal", "workarea.py")) and
                not p.isfile(p.join(self.m_dir, "internal", "RootCore.py"))):
                raise RCError("invalid RootCore installation: " + self.m_dir)
        
        else:
            self.m_dir = os.getenv("ROOTCOREDIR")
            self.m_bin = os.getenv("ROOTCOREBIN")
            self.m_obj = os.getenv("ROOTCOREOBJ")
            if not all([self.m_dir, os.path.isabs(self.m_dir),
                        self.m_bin, os.path.isabs(self.m_bin),
                        self.m_obj, os.path.isabs(self.m_obj)]):
                raise RCError("environment not correctly setup please rerun RootCore setup")
        self.m_config = self.m_bin + "/rootcore_config"

        if not self.m_dir or not os.path.isabs(self.m_dir):
            raise RCError("failed to configure ROOTCOREDIR")
        if not self.m_bin or not os.path.isabs(self.m_bin):
            raise RCError("failed to configure ROOTCOREBIN")
        if not self.m_obj or not os.path.isabs(self.m_obj):
            raise RCError("failed to configure ROOTCOREOBJ")
        pass
Example #7
0
def users_route(user_id=None):
    if request.method == 'POST':
        first_name = utils.get_field(request, 'first_name', required=True)
        last_name = utils.get_field(request, 'last_name', required=True)
        email = utils.get_field(request, 'email', required=True)
        password = utils.get_field(request, 'password')
        fb_id = utils.get_field(request, 'fb_id')

        return users.new_user(first_name, last_name, email, password, fb_id)

    if user_id is None:
        return users.get_all_users()

    return users.get_user(user_id)
Example #8
0
    def read_options(self):
        """effects: read the fields from the options file"""
        self.m_name = get_field(self.m_options_file,
                                "name",
                                default=self.m_pkgname,
                                empty=self.m_pkgname)
        self.m_url = get_field(self.m_options_file, "url", default="").split()
        self.m_md5sum = get_field(self.m_options_file,
                                  "md5sum",
                                  default=None,
                                  empty=None)
        self.m_srcdir = get_field(self.m_options_file, "src_dir", default="")
        self.m_target = os.path.join(os.getenv("ROOTCORECMT"), "local")
        self.m_binname = get_field(self.m_options_file, "binname",
                                   default="").split()
        self.m_incname = get_field(self.m_options_file, "incname",
                                   default="").split()
        self.m_libname = get_field(self.m_options_file, "libname",
                                   default="").split()

        force_local = get_field(self.m_options_file,
                                "force_local",
                                default="no",
                                empty="no")
        allow_global = get_field(self.m_options_file,
                                 "allow_global",
                                 default="no",
                                 empty="no")
        self.m_siteroot = get_field(self.m_options_file,
                                    "siteroot",
                                    empty=None)

        if allow_global == "yes":
            self.m_allow_global = True
        elif allow_global == "no":
            self.m_allow_global = False
        else:
            raise RCError("invalid value " + allow_global +
                          " for option allow_global")

        if force_local == "yes":
            self.m_force_local = True
        elif force_local == "no":
            self.m_force_local = False
        else:
            raise RCError("invalid value " + force_local +
                          " for option force_local")
        pass
Example #9
0
    def on_patch(self, req, resp, import_id, citizen_id):
        posted_data = req.context['request']

        valid = utils.citizen_validate(posted_data, update=True)

        if not valid:
            resp.status = falcon.HTTP_400
            return

        data = []
        citizen_data = utils.citizen_data_shaper(citizen_id, posted_data)
        data.append(citizen_data)

        if posted_data.get('relatives'):
            citizen_pack = tarantool_call('import_citizen_with_relative',
                                          import_id, citizen_id,
                                          posted_data['relatives'])

            relative_data = utils.relative_data_shaper(
                citizen_id=citizen_id,
                cur_relatives=utils.get_field(citizen_pack[0], 'relatives'),
                new_relatives=posted_data['relatives'],
                relatives_pack=citizen_pack[1])
        else:
            relative_data = []

        data += relative_data
        updated_citizen = tarantool_call('import_update_citizens', import_id,
                                         data)

        resp.status = falcon.HTTP_200
        resp.context['response'] = utils.format_citizen(updated_citizen)
Example #10
0
def users_search():
    if request.method == 'GET':
        return render_template('search.html')

    query = utils.get_field(request, 'query', required=True)
    user_id = utils.get_num(request, 'user_id', required=True)
    return users.search_users(query, user_id)
Example #11
0
    def find_packages_release(self, release):
        """effects: parse the release options specified to
        find_packages and pick up the packages from the base
        release"""
        myrelease=get_field(self.bin() + "/rootcore_config", "release")
        if myrelease:
            print "using release set with set_release"
            release = string.split(myrelease) + release

        rel_parser = optparse.OptionParser()
        WorkArea.init_release_options(rel_parser, False)
        (release_args, extra_release_args) = rel_parser.parse_args(release)
        if len(extra_release_args) != 0:
            rel_parser.error("incorrect number of arguments")

        WORKAREAREL = self.relPath(self.area(), self.bin())
        if os.path.isabs(WORKAREAREL):
            print "work area does not contain ROOTCOREBIN, aborting"
            print "  ROOTCOREBIN=" + self.bin()
            print "  WORKAREA=" + self.m_area
            print "  WORKAREAREL=" + WORKAREAREL
            sys.exit(1)

        self.m_packages = PackageList(self)
        for place in release_args.places:
            for pkg in WorkArea(RootCoreBin=place[0]).parsePackages():
                pkg.m_wa = self
                pkg.m_recompile = place[1]
                pkg.m_release = True
                self.m_packages.addPkg(pkg)
        self.m_pedantic = release_args.use_pedantic
        return release_args.restrict
Example #12
0
    def find_packages_release(self, release):
        """effects: parse the release options specified to
        find_packages and pick up the packages from the base
        release"""
        myrelease = get_field(self.bin() + "/rootcore_config", "release")
        if myrelease:
            print "using release set with set_release"
            release = string.split(myrelease) + release

        rel_parser = optparse.OptionParser()
        WorkArea.init_release_options(rel_parser, False)
        (release_args, extra_release_args) = rel_parser.parse_args(release)
        if len(extra_release_args) != 0:
            rel_parser.error("incorrect number of arguments")

        WORKAREAREL = self.relPath(self.area(), self.bin())
        if os.path.isabs(WORKAREAREL):
            print "work area does not contain ROOTCOREBIN, aborting"
            print "  ROOTCOREBIN=" + self.bin()
            print "  WORKAREA=" + self.m_area
            print "  WORKAREAREL=" + WORKAREAREL
            sys.exit(1)

        self.m_packages = PackageList(self)
        for place in release_args.places:
            for pkg in WorkArea(RootCoreBin=place[0]).parsePackages():
                pkg.m_wa = self
                pkg.m_recompile = place[1]
                pkg.m_release = True
                self.m_packages.addPkg(pkg)
        self.m_pedantic = release_args.use_pedantic
        return release_args.restrict
Example #13
0
 def useReflex (self):
     """returns: whether we use a Reflex dictionary"""
     if self.m_useReflex == None:
         self.m_useReflex = get_field (self.cc_makefile(),
                                       "PACKAGE_REFLEX") == "1"
         pass
     return self.m_useReflex
Example #14
0
 def getCxxFlags (self, user=False, opt=True, pedantic=False, external=False):
     """returns: the compiler flags to use when compiling code
     depending on all the packages in the list"""
     result = ""
     if not user:
         if opt:
             result = get_field (self.m_wa.root_conf(), "CXXFLAGS")
             pass
         else:
             result = get_field (self.m_wa.root_conf(), "CXXFLAGS_NOOPT")
             pass
         pass
     result = result.strip() + " -I" + self.m_wa.bin() + "/include -g -Wno-tautological-undefined-compare"
     #result = string.strip (result + " " + "-I" + self.m_wa.bin() + "/include -g")
     if not external:
         result += " -DROOTCORE"
         pass
     if not user:
         result = str(result + " " +
                      shell_exec (["root-config", "--cflags"])).strip()
         #result = string.strip (result + " " + shell_exec (["root-config", "--cflags"]))
         pass
     for var in ["CXXFLAGS", "EXTRA_CFLAGS", "CPPEXFLAGS"]:
         flags = os.getenv (var)
         if flags and flags != "":
             result = str(result + " " + flags).strip()
             #result = string.strip (result + " " + flags)
             pass
         pass
     # if not user:
     #     boostinc = os.getenv ("BOOSTINCDIR")
     #     if boostinc:
     #         result = string.strip (result + " -I" + boostinc)
     #         pass
     #     pass
     if pedantic and not external:
         result = str(result + " -pipe -W -Wall -Wno-deprecated" +
                      " -pedantic -Wwrite-strings -Wpointer-arith" +
                      " -Woverloaded-virtual -Wno-long-long" +
                      " -Wdeprecated-declarations").strip()
         pass
     for pkg in self.m_packages:
         result = str(result + " " + pkg.objflags()).strip()
         #result = string.strip (result + " " + pkg.objflags())
         pass
     return result
Example #15
0
 def harddep (self) :
     """description: all the hard dependencies reported by the
     package, i.e. the one it insists it needs in order to work"""
     dep = get_field (self.conf_makefile(), "PACKAGE_DEP")
     if dep:
         return dep.split()
         #return string.split (dep)
     return []
Example #16
0
def get_restaurants():
    if request.method == 'GET':
        return render_template('restaurants.html',
                               data=restaurants.filters_object())

    lat = utils.get_field(request, 'lat', required=True)
    lng = utils.get_field(request, 'long', required=True)
    rad = utils.get_num(request, 'radius', 1, 20, required=True)
    cuisines = utils.get_list(request, 'cuisines')
    categories = utils.get_list(request, 'categories')
    price = utils.get_num(request, 'price', required=True)
    user_id = utils.get_num(request, 'user_id', required=True)
    limit = utils.get_num(request, 'limit')
    offset = utils.get_num(request, 'offset')

    return restaurants.get_restaurants(lat, lng, rad, price, limit, offset,
                                       cuisines, categories)
Example #17
0
 def trydep (self) :
     """description: all the trial dependencies reported by the
     package, i.e. the ones it will depend on when they are there,
     but can live without when they are not there"""
     dep = get_field (self.conf_makefile(), "PACKAGE_TRYDEP")
     if dep:
         return dep.split()
         #return string.split (dep)
     return []
Example #18
0
def _append_auto_increment(lines, table, schema):
    field_name = '%s' % schema['autoIncrement']
    field = utils.get_field(schema, field_name)
    name = utils.get(field, 'name')
    sql_type = utils.get(field, 'sql_type')
    description = utils.get(field, 'description')
    lines.append('ALTER TABLE `%s`' % table)
    lines.append('  MODIFY `%s` %s AUTO_INCREMENT%s;' % (name, sql_type, description and (" COMMENT '%s'" % description) or ''))
    lines.append('')
Example #19
0
    def check_all_permissions(self, request, *args, **kwargs):
        id_ = request.GET.get('field_id', None)
        if id_ is None or not is_valid_id(id_):
            raise Http404('field_id not found or is invalid')
        field = get_field(id_)
        if field is None:
            raise Http404('field_id not found')

        if not field.security_check(request, *args, **kwargs):
            raise PermissionDenied('permission denied')

        request.__django_select2_local = field
Example #20
0
 def pedantic(self):
     """description: 2 for compiling all packages pedantic, 1 for
     compiling the packages pedantic that request it, and 0 for
     compiling no packages pedantic"""
     if self.m_pedantic == None:
         pedantic = get_field(self.config(), "use_pedantic")
         if pedantic == "2":
             self.m_pedantic = 2
         elif pedantic == "0":
             self.m_pedantic = 0
         else:
             self.m_pedantic = 1
     return self.m_pedantic
Example #21
0
    def __init__(self, wa):
        self.m_wa = wa
        self.m_pkgname = get_field("Makefile.RootCore", "PACKAGE")
        self.m_rcpkg = wa.packages().getPkg(self.m_pkgname)
        self.m_work_area = os.getenv("ROOTCORECMT")
        if not self.m_work_area:
            raise RCError("ROOTCORECMT not set, required for external package")
        self.m_conf_file = os.path.join(self.m_work_area, "configured")
        self.m_options_file = None
        if os.path.exists(self.m_conf_file):
            field = get_field(self.m_conf_file, "options_file", empty=None)
            self.m_options_file = self.m_wa.expandPath(field)
            #self.m_options_file = self.m_wa.expandPath(get_field(self.m_conf_file, "options_file", empty=None))
            pass
        if not self.m_options_file:
            self.m_options_file = os.path.join(os.getcwd(), "options")
            pass

        self.m_binname = None
        self.m_incname = None
        self.m_libname = None
        pass
Example #22
0
    def __init__ (self, wa):
        self.m_wa = wa
        self.m_pkgname = get_field ("Makefile.RootCore", "PACKAGE")
        self.m_rcpkg = wa.packages().getPkg (self.m_pkgname)
        self.m_work_area = os.getenv ("ROOTCORECMT")
        if not self.m_work_area:
            raise RCError ("ROOTCORECMT not set, required for external package")
        self.m_conf_file = os.path.join (self.m_work_area, "configured")
        self.m_options_file = None
        if os.path.exists (self.m_conf_file):
            field = get_field (self.m_conf_file, "options_file", empty=None)
            self.m_options_file = self.m_wa.expandPath(field)
            #self.m_options_file = self.m_wa.expandPath(get_field(self.m_conf_file, "options_file", empty=None))
            pass
        if not self.m_options_file:
            self.m_options_file = os.path.join (os.getcwd(), "options")
            pass

        self.m_binname = None
        self.m_incname = None
        self.m_libname = None
        pass
Example #23
0
 def pedantic(self):
     """description: 2 for compiling all packages pedantic, 1 for
     compiling the packages pedantic that request it, and 0 for
     compiling no packages pedantic"""
     if self.m_pedantic == None:
         pedantic = get_field(self.config(), "use_pedantic")
         if pedantic == "2":
             self.m_pedantic = 2
         elif pedantic == "0":
             self.m_pedantic = 0
         else:
             self.m_pedantic = 1
     return self.m_pedantic
Example #24
0
    def read_options (self):
        """effects: read the fields from the options file"""
        self.m_name = get_field (self.m_options_file, "name",
                                 default=self.m_pkgname, empty=self.m_pkgname)
        self.m_url = get_field (self.m_options_file, "url", default="").split()
        self.m_md5sum = get_field (self.m_options_file, "md5sum",
                                   default=None, empty=None)
        self.m_srcdir = get_field (self.m_options_file, "src_dir", default="")
        self.m_target = os.path.join (os.getenv ("ROOTCORECMT"), "local")
        self.m_binname = get_field (self.m_options_file, "binname",
                                    default="").split()
        self.m_incname = get_field (self.m_options_file, "incname",
                                    default="").split()
        self.m_libname = get_field (self.m_options_file, "libname",
                                    default="").split()

        force_local = get_field (self.m_options_file, "force_local",
                                 default="no", empty="no")
        allow_global = get_field (self.m_options_file, "allow_global",
                                  default="no", empty="no")
        self.m_siteroot = get_field (self.m_options_file, "siteroot", empty=None)

        if allow_global == "yes":
            self.m_allow_global = True
        elif allow_global == "no":
            self.m_allow_global = False
        else:
            raise RCError ("invalid value " + allow_global +
                           " for option allow_global")

        if force_local == "yes":
            self.m_force_local = True
        elif force_local == "no":
            self.m_force_local = False
        else:
            raise RCError ("invalid value " + force_local +
                           " for option force_local")
        pass
Example #25
0
 def area(self):
     """description: the base directory of the work area, i.e. the
     directory in which find_packages was called"""
     if not self.m_area:
         rel = get_field(self.m_config, "workareaRelative", default="")
         if os.path.isabs(rel):
             raise RCError("workareaRelative set to invalid value '" + \
                           rel + "' in " + self.m_config)
         self.m_area = self.bin()
         if rel:
             while rel != "" and rel != ".":
                 self.m_area = os.path.dirname(self.m_area)
                 rel = os.path.dirname(rel)
     return self.m_area
Example #26
0
 def area(self):
     """description: the base directory of the work area, i.e. the
     directory in which find_packages was called"""
     if not self.m_area:
         rel = get_field(self.m_config, "workareaRelative", default="")
         if os.path.isabs(rel):
             raise RCError("workareaRelative set to invalid value '" + \
                           rel + "' in " + self.m_config)
         self.m_area = self.bin()
         if rel:
             while rel != "" and rel != ".":
                 self.m_area = os.path.dirname(self.m_area)
                 rel = os.path.dirname(rel)
     return self.m_area
Example #27
0
 def preload (self) :
     """description: the list of external libraries this package
     needs to have loaded/linked for its own library to work"""
     if self.m_preload == None:
         preload = get_field (self.cc_makefile(), "PACKAGE_PRELOAD")
         if preload:
             self.m_preload = preload.split()
             #self.m_preload = string.split (preload)
             pass
         else:
             self.m_preload = []
             pass
         pass
     return self.m_preload
Example #28
0
 def nocc (self) :
     """description: whether the package has no library to compile
     rationale: some packages contain only header files.  to avoid
     an error when compiling them (and to avoid adding a dummy
     source file) I introduced this flag"""
     if self.m_nocc == None:
         nocc = get_field (self.cc_makefile(), "PACKAGE_NOCC")
         if nocc == "1":
             self.m_nocc = True
             pass
         else:
             self.m_nocc = False
             pass
         pass
     return self.m_nocc
Example #29
0
    def complete_locations(self):
        """effects: add in all the locations from global, site-root
        and local installation"""

        if self.m_force_local:
            self.m_locations = [ExternalLocationLocal(self)]
            return

        self.m_locations = []

        if self.m_allow_global:
            self.m_locations.append(ExternalLocationGlobal(self))
            pass

        if self.m_siteroot:
            SITEROOT = os.getenv("SITEROOT")
            if SITEROOT:
                shell_args = [
                    "find",
                    os.path.join(SITEROOT, self.m_siteroot), "-type", "d",
                    "-name", "lib"
                ]
                for libdir in shell_exec(shell_args).split("\n"):
                    if libdir.find(os.getenv("CMTCONFIG")) != -1:
                        print "found via SITEROOT: " + libdir
                        maindir = os.path.dirname(libdir)
                        incdir = os.path.join(maindir, "include")
                        loc = incdir + ":" + libdir
                        self.m_locations.append(ExternalLocation(self, loc))
                        pass
                    pass
                pass
            pass

        #for location in string.split (get_field (self.m_options_file, "locations", default=""), " "):
        for location in get_field(self.m_options_file, "locations",
                                  default="").split():
            location = expand_env(location)
            if location and location != "":
                self.m_locations.append(ExternalLocation(self, location))
                pass
            pass

        if os.path.exists("install"):
            self.m_locations.append(ExternalLocationLocal(self))
            pass
        pass
Example #30
0
    def complete_locations (self):
        """effects: add in all the locations from global, site-root
        and local installation"""

        if self.m_force_local:
            self.m_locations = [ExternalLocationLocal (self)]
            return

        self.m_locations = []

        if self.m_allow_global:
            self.m_locations.append (ExternalLocationGlobal (self))
            pass

        if self.m_siteroot:
            SITEROOT = os.getenv ("SITEROOT")
            if SITEROOT:
                shell_args = ["find", os.path.join (SITEROOT, self.m_siteroot),
                              "-type", "d", "-name", "lib"]
                for libdir in shell_exec (shell_args).split("\n"):
                    if libdir.find (os.getenv("CMTCONFIG")) != -1:
                        print "found via SITEROOT: " + libdir
                        maindir = os.path.dirname (libdir)
                        incdir = os.path.join (maindir, "include")
                        loc = incdir + ":" + libdir
                        self.m_locations.append (ExternalLocation(self, loc))
                        pass
                    pass
                pass
            pass

        #for location in string.split (get_field (self.m_options_file, "locations", default=""), " "):
        for location in get_field (self.m_options_file, "locations",
                                   default="").split():
            location = expand_env (location)
            if location and location != "":
                self.m_locations.append (ExternalLocation (self, location))
                pass
            pass

        if os.path.exists ("install"):
            self.m_locations.append (ExternalLocationLocal (self))
            pass
        pass
Example #31
0
 def auto (self) :
     """description: the auto-dependency reported by the package.
     this is an integer which is 0 for regular packages.  if this
     is greater than 0 this package will be added to all other
     packages, except those with a greater auto-dependency
     setting
     rationale: sometimes I introduce global packages that all
     other packages should use, but since it is is impractical to
     update the dependencies for all other packages those packages
     should just set an auto-dependency instead"""
     if not self.m_auto:
         dep = get_field (self.conf_makefile(), "PACKAGE_AUTODEP")
         if dep:
             self.m_auto = int (dep)
             pass
         else:
             self.m_auto = 0
             pass
     return self.m_auto
Example #32
0
File: views.py Project: GaloC/gplib
def get_cita(request, item_id):
    item = WFItem.get(item_id)

    cita_fields = [('100', 'a'), ('245', 'a'),
            ('260', 'b'), ('260', 'c')]
    cita = ''
    for f, sf in cita_fields:
        cfield = get_field(item, f, sf)
        if not cfield:
            #print "Invaid Cita!", f, sf
            cita = 'Cita no encontrada'
            break
        if sf:
            cfield = cfield[0]
        cita += cfield + ' '
    print "CITA"
    print cita

    data = simplejson.dumps({'success': True,
        'message': 'Success', 'data': cita})
    return HttpResponse(data, mimetype='application/json')
Example #33
0
    def find_packages_find(self, area, allowNesting):
        """effects: search for packages in the work area"""
        for filename in os.listdir(area):
            dir = os.path.join(area, filename)
            is_package = False
            if os.path.exists(os.path.join(dir, "cmt", "Makefile.RootCore")):
                is_package = True
                name=os.path.basename(dir)
                name2=get_field(dir + "/cmt/Makefile.RootCore", "PACKAGE")
                if not name2:
                    raise Exception("failed to read package name from " +
                                    dir + "/cmt/Makefile.RootCore")
                if name != name2:
                    #raise Exception("package " + dir + " should have name " + name2 + "\n" +
                    #                "please rename it to " + os.path.dirname(dir) + "/" + name2 + " by typing\n" +
                    #                "  mv '" + dir + "' '" + os.path.dirname(dir) + "/" + name2 + "'")
                    dirname = os.path.dirname(dir) + "/" + name2
                    exstr = "package %s should have name %s\n" % (dir, name2)
                    exstr += "please rename it to %s by typing\n" % dirname
                    exstr += "  mv '%s' '%s'" % (dir, dirname)
                    raise Exception(exstr)
                pkg2 = self.m_packages.getPkg(name)
                if pkg2 and pkg2.release() == 0:
                    raise Exception("duplicate packages, please remove one of them:\n" +
                                    "  " + dir + "\n" +
                                    "  " + pkg2.srcdir())

                pkg = PackageInfo(self)
                pkg.m_name = name
                pkg.m_srcdir = dir
                pkg.m_release = False
                pkg.m_recompile = True
                self.m_packages.addPkg(pkg)
            if((not is_package or allowNesting) and os.path.isdir(dir) and
                (area != self.bin() or
                 (filename != "RootCore" and filename != "bin"          and
                  filename != "data"     and filename != "include"      and
                  filename != "lib"      and filename != "obj"          and 
                  filename != "python"   and filename != "user_scripts" ))):
                self.find_packages_find(dir, allowNesting)
Example #34
0
    def find_packages_find(self, area, allowNesting):
        """effects: search for packages in the work area"""
        for filename in os.listdir(area):
            dir = os.path.join(area, filename)
            is_package = False
            if os.path.exists(os.path.join(dir, "cmt", "Makefile.RootCore")):
                is_package = True
                name = os.path.basename(dir)
                name2 = get_field(dir + "/cmt/Makefile.RootCore", "PACKAGE")
                if not name2:
                    raise Exception("failed to read package name from " + dir +
                                    "/cmt/Makefile.RootCore")
                if name != name2:
                    #raise Exception("package " + dir + " should have name " + name2 + "\n" +
                    #                "please rename it to " + os.path.dirname(dir) + "/" + name2 + " by typing\n" +
                    #                "  mv '" + dir + "' '" + os.path.dirname(dir) + "/" + name2 + "'")
                    dirname = os.path.dirname(dir) + "/" + name2
                    exstr = "package %s should have name %s\n" % (dir, name2)
                    exstr += "please rename it to %s by typing\n" % dirname
                    exstr += "  mv '%s' '%s'" % (dir, dirname)
                    raise Exception(exstr)
                pkg2 = self.m_packages.getPkg(name)
                if pkg2 and pkg2.release() == 0:
                    raise Exception(
                        "duplicate packages, please remove one of them:\n" +
                        "  " + dir + "\n" + "  " + pkg2.srcdir())

                pkg = PackageInfo(self)
                pkg.m_name = name
                pkg.m_srcdir = dir
                pkg.m_release = False
                pkg.m_recompile = True
                self.m_packages.addPkg(pkg)
            if ((not is_package or allowNesting) and os.path.isdir(dir) and
                (area != self.bin() or
                 (filename != "RootCore" and filename != "bin"
                  and filename != "data" and filename != "include"
                  and filename != "lib" and filename != "obj"
                  and filename != "python" and filename != "user_scripts"))):
                self.find_packages_find(dir, allowNesting)
Example #35
0
    def ut_test_list(self,recursive):
        """returns: the list of tests we have"""
        recursive_ut = {}
        for ut in get_field (self.conf_makefile(), "PACKAGE_RECURSIVE_UT", default="").split() :
            recursive_ut[ut] = ""
            pass

        result = []
        name_expr = re.compile("^((ut|gt|it|pt)_[^.]*)(.*)$")
        testdir = os.path.join(self.srcdir(), "test")
        if os.path.isdir(testdir):
            for file in os.listdir(testdir):
                test = None
                match = name_expr.match(file)
                if match:
                    if match.group(3) == ".cxx":
                        test = os.path.join(self.testdir(), match.group(1))
                        pass
                    elif match.group(3) == ".sh" or match.group(3) == ".py" or match.group(3) == ".C":
                        test = os.path.join(testdir, file)
                        pass
                    pass
                if test :
                    rec = False
                    name = os.path.basename (test)
                    if name in recursive_ut :
                        rec = True
                        del recursive_ut[name]
                        pass
                    if rec or not recursive :
                        result.append (test)
                        pass
                    pass
                pass
            pass
        for test in recursive_ut.keys() :
            raise RCError ("unknown recursive test: " + test)
        return result
Example #36
0
def get_cita(request, item_id):
    item = WFItem.get(item_id)

    cita_fields = [('100', 'a'), ('245', 'a'), ('260', 'b'), ('260', 'c')]
    cita = ''
    for f, sf in cita_fields:
        cfield = get_field(item, f, sf)
        if not cfield:
            #print "Invaid Cita!", f, sf
            cita = 'Cita no encontrada'
            break
        if sf:
            cfield = cfield[0]
        cita += cfield + ' '
    print "CITA"
    print cita

    data = simplejson.dumps({
        'success': True,
        'message': 'Success',
        'data': cita
    })
    return HttpResponse(data, mimetype='application/json')
Example #37
0
 def read_location (self):
     result = ExternalLocation (self, None)
     if not os.path.exists (self.m_conf_file):
         raise RCError ("failed to read external location, rerun compile")
     expandPath = self.m_wa.expandPath
     result.m_bindir = expandPath (get_field (self.m_conf_file, "bindir"),
                                   self.m_rcpkg.outdir())
     result.m_libdir = expandPath (get_field (self.m_conf_file, "libdir"),
                                   self.m_rcpkg.outdir())
     result.m_incdir = expandPath (get_field (self.m_conf_file, "incdir"),
                                   self.m_rcpkg.outdir())
     if not result.m_bindir and not result.m_libdir and not result.m_incdir:
         result = ExternalLocationGlobal (self)
         pass
     self.m_binname = get_field (self.m_conf_file, "binname").split()
     self.m_libname = get_field (self.m_conf_file, "libname").split()
     self.m_incname = get_field (self.m_conf_file, "incname").split()
     #self.m_binname = string.split (get_field (self.m_conf_file, "binname"))
     #self.m_libname = string.split (get_field (self.m_conf_file, "libname"))
     #self.m_incname = string.split (get_field (self.m_conf_file, "incname"))
     return result
Example #38
0
 def read_location(self):
     result = ExternalLocation(self, None)
     if not os.path.exists(self.m_conf_file):
         raise RCError("failed to read external location, rerun compile")
     expandPath = self.m_wa.expandPath
     result.m_bindir = expandPath(get_field(self.m_conf_file, "bindir"),
                                  self.m_rcpkg.outdir())
     result.m_libdir = expandPath(get_field(self.m_conf_file, "libdir"),
                                  self.m_rcpkg.outdir())
     result.m_incdir = expandPath(get_field(self.m_conf_file, "incdir"),
                                  self.m_rcpkg.outdir())
     if not result.m_bindir and not result.m_libdir and not result.m_incdir:
         result = ExternalLocationGlobal(self)
         pass
     self.m_binname = get_field(self.m_conf_file, "binname").split()
     self.m_libname = get_field(self.m_conf_file, "libname").split()
     self.m_incname = get_field(self.m_conf_file, "incname").split()
     #self.m_binname = string.split (get_field (self.m_conf_file, "binname"))
     #self.m_libname = string.split (get_field (self.m_conf_file, "libname"))
     #self.m_incname = string.split (get_field (self.m_conf_file, "incname"))
     return result
Example #39
0
 def getCxx(self, user=False):
     """returns: the c++ compiler to be used"""
     return get_field(self.root_conf(), "CXX")
Example #40
0
 def getLd(self, user=False):
     """returns: the c++ linker to be used"""
     return get_field(self.root_conf(), "LD")
Example #41
0
 def getLd(self, user=False):
     """returns: the c++ linker to be used"""
     return get_field(self.root_conf(), "LD")
Example #42
0
 def getCxx(self, user=False):
     """returns: the c++ compiler to be used"""
     return get_field(self.root_conf(), "CXX")
Example #43
0
    def root_conf(self):
        """effects: determine the root parameters used for compilation
        returns: the path to the configuration file generated
        failures: incompatible root installation"""
        if not self.m_root_conf:
            file = os.path.join(self.bin(), "root_config_" + self.arch())
            ROOTSYS = os.getenv("ROOTSYS")
            if ROOTSYS == None:
                if os.path.isfile(file):
                    ROOTSYS = get_field(file, "ROOTSYS")
                    if ROOTSYS and ROOTSYS != "":
                        raise RCError(
                            "no valid root version found, try setting up root using\n"
                            + "  source " + ROOTSYS + "/bin/thisroot.sh")
                if os.path.isdir(
                        "/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase"):
                    raise RCError(
                        "no valid root version found, try setting up root using\n"
                        +
                        "  export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase\n"
                        +
                        "  source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh\n"
                        + "  localSetupROOT")
                if shell_exec(["which", "root-config"], allowFail=True) != "":
                    raise RCError(
                        "no valid root version found, try setting up root using\n"
                        + "  source `root-config --prefix`/bin/thisroot.sh")
                raise RCError(
                    "no valid root version found, please set up root")

            if os.path.isfile(file):
                myrootversion = get_field(file, "ROOT_VERSION")
                if not myrootversion:
                    set_field(file, "ROOT_VERSION", self.root_version())
                elif self.root_version() != myrootversion:
                    myrootsys = get_field(file, "ROOTSYS")
                    raise RCError(
                        "Root Version: " + self.root_version() + "\n" +
                        "is not the same as previous version:\n" + "   " +
                        myrootversion + "\n" +
                        "either set up the correct root version e.g. via:\n" +
                        "  source " + myrootsys + "/bin/thisroot.sh\n" +
                        "or clean out the old object files via:\n" +
                        "  rc clean")
                self.m_root_conf = file
                return file

            myarch = shell_exec(["root-config", "--etcdir"]) + "/Makefile.arch"
            if not os.path.isfile(myarch):
                myarch = os.getenv(
                    "ROOTSYS") + "/share/doc/root/test/Makefile.arch"
            if not os.path.isfile(myarch):
                shell_args = [
                    "find",
                    os.getenv("ROOTSYS") + "/.", "-name", "Makefile.arch"
                ]
                search = shell_exec(shell_args).strip().split("\n")
                if len(search) > 0:
                    myarch = search[0]
            if not os.path.isfile(myarch):
                raise RCError("failed to find Makefile.arch in " +
                              os.getenv("ROOTSYS"))

            with open(file + "-", "w") as f:
                shell_args = [
                    "make", "-f",
                    self.dir() + "/Makefile-print", "MAKEFILE_ARCH=" + myarch
                ]
                rc = shell_exec(shell_args, stdout=f, returnRC=True)
            if rc != 0:
                raise RCError("could not determine compilation parameters")
            os.rename(file + "-", file)
            self.m_root_conf = file
        return self.m_root_conf
Example #44
0
    def __init__(self, RootCoreBin=None, RootCoreDir=None):
        self.m_area = None
        self.m_areaList = None
        self.m_packages = None
        self.m_arch = os.getenv("ROOTCORECONFIG")
        if not self.m_arch:
            self.m_arch = "generic"
            pass
        self.m_root_conf = None
        self.m_pedantic = None

        if RootCoreDir and not os.path.isabs(RootCoreDir):
            RootCoreDir = os.path.join(os.getcwd(), RootCoreDir)
        if RootCoreBin and not os.path.isabs(RootCoreBin):
            RootCoreBin = os.path.join(os.getcwd(), RootCoreBin)

        if RootCoreDir != None:
            self.m_dir = RootCoreDir
            if RootCoreBin != None:
                self.m_bin = RootCoreBin
            else:
                self.m_bin = self.m_dir
            self.m_obj = os.path.join(self.m_bin, "obj")
        elif RootCoreBin != None:
            self.m_bin = RootCoreBin
            self.m_config = self.m_bin + "/rootcore_config"
            self.m_dir = self.expandPath(
                get_field(self.m_config, "rootcoredir"))
            if not self.m_dir or self.m_dir == "":
                self.m_dir = RootCoreBin
            self.m_obj = self.expandPath(
                get_field(self.m_config, "rootcoreobj"))
            if not self.m_obj or self.m_obj == "":
                self.m_obj = os.path.join(RootCoreBin, "obj")

            p = os.path
            if (not p.isfile(p.join(self.m_dir, "internal", "workarea.py"))
                    and not p.isfile(
                        p.join(self.m_dir, "internal", "RootCore.py"))):
                raise RCError("invalid RootCore installation: " + self.m_dir)

        else:
            self.m_dir = os.getenv("ROOTCOREDIR")
            self.m_bin = os.getenv("ROOTCOREBIN")
            self.m_obj = os.getenv("ROOTCOREOBJ")
            if not all([
                    self.m_dir,
                    os.path.isabs(self.m_dir), self.m_bin,
                    os.path.isabs(self.m_bin), self.m_obj,
                    os.path.isabs(self.m_obj)
            ]):
                raise RCError(
                    "environment not correctly setup please rerun RootCore setup"
                )
        self.m_config = self.m_bin + "/rootcore_config"

        if not self.m_dir or not os.path.isabs(self.m_dir):
            raise RCError("failed to configure ROOTCOREDIR")
        if not self.m_bin or not os.path.isabs(self.m_bin):
            raise RCError("failed to configure ROOTCOREBIN")
        if not self.m_obj or not os.path.isabs(self.m_obj):
            raise RCError("failed to configure ROOTCOREOBJ")
        pass
Example #45
0
 def get_field(self, field, subfield=None, first=True):
     """
     Helper that returns field or subfield, or None if can't find it
     """
     return get_field(self, field, subfield, first)