- Add copyright notices to existing builtin python policies
- Implement system to dinamically pass plugins and policies search paths to the sgpemv2 binary and tests (class GlobalSettings) - Drastically reduce usage of hardcoded paths in code except as default overridable values git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@514 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
24a0194368
commit
92e6f3be2b
14
Makefile.am
14
Makefile.am
|
@ -38,7 +38,7 @@ bin_PROGRAMS =
|
|||
plugin_LTLIBRARIES =
|
||||
noinst_HEADERS =
|
||||
pkglib_LTLIBRARIES =
|
||||
tests_PYTHON =
|
||||
noinst_PYTHON =
|
||||
EXTRA_DIST =
|
||||
MAINTAINERCLEANFILES =
|
||||
MOSTLYCLEANFILES =
|
||||
|
@ -120,7 +120,6 @@ src_backend_libbackend_la_CPPFLAGS = \
|
|||
-I@top_srcdir@ \
|
||||
-DPOLDIR="\"$(policiesdir)\"" \
|
||||
-DPLUGDIR="\"$(plugindir)\"" \
|
||||
-DMODDIR="\"$(moduledir)\"" \
|
||||
-DLOCALEDIR="\"$(localedir)\"" \
|
||||
$(PYTHON_CPPFLAGS) \
|
||||
$(GLIBMM_CFLAGS)
|
||||
|
@ -134,6 +133,7 @@ src_backend_libbackend_la_LDFLAGS = \
|
|||
|
||||
# Please keep this in sorted order:
|
||||
src_backend_libbackend_la_SOURCES = \
|
||||
src/backend/global_settings.cc \
|
||||
src/backend/history.cc \
|
||||
src/backend/observed_subject.cc \
|
||||
src/backend/policy.cc \
|
||||
|
@ -150,6 +150,7 @@ src_backend_libbackend_la_SOURCES = \
|
|||
|
||||
pkginclude_HEADERS = \
|
||||
config.h \
|
||||
src/backend/global_settings.hh \
|
||||
src/backend/history.hh \
|
||||
src/backend/observed_subject.hh \
|
||||
src/backend/plugin.hh \
|
||||
|
@ -176,8 +177,6 @@ bin_PROGRAMS += sgpemv2
|
|||
|
||||
sgpemv2_CPPFLAGS = \
|
||||
-I@top_srcdir@ \
|
||||
-DPLUGDIR="\"$(plugindir)\"" \
|
||||
-DMODDIR="\"$(moduledir)\"" \
|
||||
-DLOCALEDIR="\"$(localedir)\"" \
|
||||
$(CAIRO_CFLAGS) \
|
||||
$(GTKMM_CFLAGS) \
|
||||
|
@ -228,7 +227,6 @@ plugin_LTLIBRARIES += src/backend/pyloader/libpyloader.la
|
|||
|
||||
src_backend_pyloader_libpyloader_la_CPPFLAGS = \
|
||||
-I@top_srcdir@ \
|
||||
-DPOLDIR="\"$(policiesdir)\"" \
|
||||
-DMODDIR="\"$(pyloaderdir)\"" \
|
||||
-DLOCALEDIR="\"$(localedir)\"" \
|
||||
$(PYTHON_CPPFLAGS) \
|
||||
|
@ -326,12 +324,10 @@ policies_PYTHON = \
|
|||
|
||||
# DEJATOOL = src/testsuite/example-test.exp
|
||||
|
||||
tests_PROGRAMS = src/testsuite/test-python_loader
|
||||
noinst_PROGRAMS = src/testsuite/test-python_loader
|
||||
|
||||
src_testsuite_test_python_loader_CPPFLAGS = \
|
||||
-I@top_srcdir@/src \
|
||||
-DPOLDIR="\"$(testsdir)\"" \
|
||||
-DMODDIR="\"$(pyloaderdir)\"" \
|
||||
$(PYTHON_CPPFLAGS) \
|
||||
$(GLIBMM_CFLAGS) \
|
||||
$(GTHREAD_CFLAGS)
|
||||
|
@ -348,7 +344,7 @@ src_testsuite_test_python_loader_SOURCES = \
|
|||
src/observer.cc \
|
||||
src/simulation.cc
|
||||
|
||||
tests_PYTHON += src/testsuite/python_loader_configure.py \
|
||||
noinst_PYTHON += src/testsuite/python_loader_configure.py \
|
||||
src/testsuite/python_loader_sort_queue.py \
|
||||
src/testsuite/python_loader_is_preemptive.py \
|
||||
src/testsuite/python_loader_get_time_slice.py
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
// src/global_settings.cc - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
// This file is part of SGPEMv2.
|
||||
//
|
||||
// This is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// SGPEMv2 is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "config.h"
|
||||
#include "global_settings.hh"
|
||||
|
||||
using namespace sgpem;
|
||||
|
||||
GlobalSettings* GlobalSettings::_instance = 0;
|
||||
|
||||
GlobalSettings&
|
||||
GlobalSettings::instance()
|
||||
{
|
||||
if(!_instance)
|
||||
_instance = new GlobalSettings();
|
||||
return *_instance;
|
||||
}
|
||||
|
||||
|
||||
GlobalSettings::GlobalSettings()
|
||||
: _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR)
|
||||
{}
|
||||
|
||||
|
||||
GlobalSettings::dir_iterator
|
||||
GlobalSettings::policies_dir_begin() const
|
||||
{
|
||||
return _pol_dirs.begin();
|
||||
}
|
||||
|
||||
|
||||
GlobalSettings::dir_iterator
|
||||
GlobalSettings::policies_dir_end() const
|
||||
{
|
||||
return _pol_dirs.end();
|
||||
}
|
||||
|
||||
|
||||
GlobalSettings::dir_iterator
|
||||
GlobalSettings::modules_dir_begin() const
|
||||
{
|
||||
return _mod_dirs.begin();
|
||||
}
|
||||
|
||||
|
||||
GlobalSettings::dir_iterator
|
||||
GlobalSettings::modules_dir_end() const
|
||||
{
|
||||
return _mod_dirs.end();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GlobalSettings::add_modules_dir(const Glib::ustring& moddir)
|
||||
{
|
||||
_mod_dirs.insert(_mod_dirs.begin(), moddir);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GlobalSettings::add_policies_dir(const Glib::ustring& poldir)
|
||||
{
|
||||
_pol_dirs.insert(_pol_dirs.begin(), poldir);
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
// src/global_settings.hh - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
// This file is part of SGPEMv2.
|
||||
//
|
||||
// This is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// SGPEMv2 is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#ifndef GLOBAL_SETTINGS_HH
|
||||
#define GLOBAL_SETTINGS_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
#include <vector>
|
||||
|
||||
namespace sgpem {
|
||||
class GlobalSettings;
|
||||
}
|
||||
|
||||
#include "config.h"
|
||||
|
||||
namespace sgpem {
|
||||
class SG_DLLEXPORT GlobalSettings {
|
||||
public:
|
||||
typedef std::vector<Glib::ustring>::const_iterator dir_iterator;
|
||||
|
||||
static GlobalSettings& instance();
|
||||
|
||||
dir_iterator modules_dir_begin() const;
|
||||
dir_iterator modules_dir_end() const;
|
||||
|
||||
dir_iterator policies_dir_begin() const;
|
||||
dir_iterator policies_dir_end() const;
|
||||
|
||||
void add_modules_dir(const Glib::ustring& moddir);
|
||||
void add_policies_dir(const Glib::ustring& poldir);
|
||||
|
||||
private:
|
||||
GlobalSettings();
|
||||
GlobalSettings(const GlobalSettings&);
|
||||
GlobalSettings& operator=(const GlobalSettings&);
|
||||
|
||||
static GlobalSettings* _instance;
|
||||
std::vector<Glib::ustring> _mod_dirs;
|
||||
std::vector<Glib::ustring> _pol_dirs;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -19,25 +19,50 @@
|
|||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "python_policy_manager.hh"
|
||||
#include "../global_settings.hh"
|
||||
|
||||
#include <Python.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <glibmm/timer.h>
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
using namespace sgpem;
|
||||
|
||||
|
||||
|
||||
// Concatenate a string with all the policies directories
|
||||
struct pol_dirs_concat : public std::unary_function<void, const Glib::ustring&>
|
||||
{
|
||||
public:
|
||||
pol_dirs_concat(Glib::ustring& cat) : _cat(cat) {}
|
||||
void operator()(const Glib::ustring& add)
|
||||
{
|
||||
// Please note that this string will end finishing with
|
||||
// and additional ","!
|
||||
_cat += "'" + add + "', ";
|
||||
}
|
||||
private:
|
||||
Glib::ustring& _cat;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//static object
|
||||
PythonPolicyManager* PythonPolicyManager::_instance = NULL;
|
||||
|
||||
|
||||
PythonPolicyManager::PythonPolicyManager()
|
||||
: _initialized(false)
|
||||
{
|
||||
PyEval_InitThreads();
|
||||
}
|
||||
|
||||
|
||||
PythonPolicyManager* const
|
||||
PythonPolicyManager::get_instance()
|
||||
{
|
||||
|
@ -46,6 +71,7 @@ PythonPolicyManager::get_instance()
|
|||
return _instance;
|
||||
}
|
||||
|
||||
|
||||
Policy&
|
||||
PythonPolicyManager::get_policy()
|
||||
{
|
||||
|
@ -53,6 +79,7 @@ PythonPolicyManager::get_policy()
|
|||
return *_python_policy;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PythonPolicyManager::init()
|
||||
{
|
||||
|
@ -63,14 +90,20 @@ PythonPolicyManager::init()
|
|||
Py_Initialize();
|
||||
_initialized = true;
|
||||
|
||||
// The following line is ugly, but necessary if we use
|
||||
// The following lines are ugly, but necessary if we use
|
||||
// non-standard installation directories. Theoretically,
|
||||
// it should be up to the user to set correct
|
||||
// environment variables.
|
||||
// FIXME: find better way to achieve this.
|
||||
|
||||
PyRun_SimpleString("import sys\n"
|
||||
"sys.path[:0] = [ '" MODDIR "', '" POLDIR "' ]\n");
|
||||
Glib::ustring importdirs = "import sys\n"
|
||||
"sys.path[:0] = [ ";
|
||||
for_each(GlobalSettings::instance().policies_dir_begin(),
|
||||
GlobalSettings::instance().policies_dir_end(),
|
||||
pol_dirs_concat(importdirs));
|
||||
importdirs += " '" MODDIR "' ]\n";
|
||||
|
||||
PyRun_SimpleString(importdirs.c_str());
|
||||
|
||||
// Okay, here we go.
|
||||
// Black magic at work.
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
# src/builtin-policies/fcfs.py - Copyright 2005, 2006, University
|
||||
# of Padova, dept. of Pure and Applied
|
||||
# Mathematics
|
||||
#
|
||||
# This file is part of SGPEMv2.
|
||||
#
|
||||
# This is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# SGPEMv2 is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with SGPEMv2; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
from Policy import Policy
|
||||
import sys
|
||||
|
||||
|
@ -15,8 +36,6 @@ class fcfs(Policy) :
|
|||
return -1
|
||||
|
||||
def sort_queue(self, event, queue):
|
||||
#while True:
|
||||
# pass
|
||||
cmpf = lambda a, b: \
|
||||
a.get_schedulable().get_arrival_time() < \
|
||||
b.get_schedulable().get_arrival_time()
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
# src/builtin-policies/sjf.py - Copyright 2005, 2006, University
|
||||
# of Padova, dept. of Pure and Applied
|
||||
# Mathematics
|
||||
#
|
||||
# This file is part of SGPEMv2.
|
||||
#
|
||||
# This is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# SGPEMv2 is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with SGPEMv2; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
from Policy import Policy
|
||||
import sys
|
||||
|
||||
|
|
40
src/main.cc
40
src/main.cc
|
@ -34,13 +34,16 @@
|
|||
#include "backend/process.hh"
|
||||
#include "backend/policy.hh"
|
||||
#include "backend/policy_parameters.hh"
|
||||
#include "backend/global_settings.hh"
|
||||
#include "standard_io.hh"
|
||||
#include "text_simulation.hh"
|
||||
|
||||
#include <glibmm/module.h>
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -50,6 +53,32 @@ using namespace sgpem;
|
|||
using namespace memory;
|
||||
using Glib::ustring;
|
||||
|
||||
|
||||
static void load_pyloader_plugin() {
|
||||
// FIXME: this will need to be moved to an
|
||||
// appropriate PluginManager class in the backend,
|
||||
// and the Makefile fixed accordingly (partly done).
|
||||
using Glib::Module;
|
||||
|
||||
// Leaks willingly:
|
||||
Module* pyloader = 0;
|
||||
|
||||
GlobalSettings::dir_iterator it = GlobalSettings::instance().modules_dir_begin();
|
||||
while(it != GlobalSettings::instance().modules_dir_end()) {
|
||||
std::string pyloader_path = Module::build_path(*it, "pyloader");
|
||||
pyloader = new Module(pyloader_path);
|
||||
if(*pyloader) break;
|
||||
else delete pyloader;
|
||||
it++;
|
||||
}
|
||||
|
||||
if(!*pyloader)
|
||||
std::cerr << Module::get_last_error() << std::endl;
|
||||
|
||||
// For the moment, we want to be sure it has been loaded:
|
||||
assert(*pyloader);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
|
@ -59,20 +88,10 @@ main(int argc, char* argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
|
||||
// FIXME: this will need to be moved to an
|
||||
// appropriate PluginManager class in the backend,
|
||||
// and the Makefile fixed accordingly
|
||||
using Glib::Module;
|
||||
std::string pyloader_path = Module::build_path(PLUGDIR, "pyloader");
|
||||
Module pyloader(pyloader_path);
|
||||
std::cerr << Module::get_last_error() << std::endl;
|
||||
assert(pyloader);
|
||||
|
||||
// Set up Glib thread support
|
||||
Glib::thread_init();
|
||||
|
||||
|
||||
// Parses options and prepares vector with
|
||||
// filenames of documents to be opened
|
||||
vector<string> filenames;
|
||||
|
@ -83,6 +102,7 @@ main(int argc, char* argv[])
|
|||
filenames.insert(filenames.begin(), a_ptr, a_ptr+a_count);
|
||||
}
|
||||
|
||||
load_pyloader_plugin();
|
||||
|
||||
// Create an INITIAL STATE
|
||||
Process p1("P1", 0,5,1);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "main.hh"
|
||||
#include "backend/global_settings.hh"
|
||||
#include "parse_opts.hh"
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
|
@ -39,81 +39,102 @@ static void display_help();
|
|||
void
|
||||
parse_options(int& argc, char**& argv)
|
||||
{
|
||||
print_license();
|
||||
using sgpem::GlobalSettings;
|
||||
|
||||
print_license();
|
||||
|
||||
static const char* short_options = "nh";
|
||||
static const char* short_options = "NhP:M:";
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
// Initialize the array for GNU long options
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"no-gui", no_argument, NULL, 'n' },
|
||||
{"help", no_argument, NULL, 'h' },
|
||||
};
|
||||
int option_index = 0;
|
||||
#endif
|
||||
|
||||
int opt;
|
||||
do
|
||||
{
|
||||
#ifdef _GNU_SOURCE
|
||||
opt = getopt_long(argc, argv, short_options,
|
||||
long_options, &option_index);
|
||||
#else
|
||||
opt = getopt(argc, argv, short_options);
|
||||
#endif
|
||||
#ifdef _GNU_SOURCE
|
||||
// Initialize the array for GNU long options
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"no-gui", no_argument, NULL, 'N' },
|
||||
{"help", no_argument, NULL, 'h' },
|
||||
{"policies-dir", required_argument, NULL, 'P'},
|
||||
{"modules-dir", required_argument, NULL, 'M'}
|
||||
};
|
||||
int option_index = 0;
|
||||
#endif
|
||||
|
||||
int opt;
|
||||
do
|
||||
{
|
||||
#ifdef _GNU_SOURCE
|
||||
opt = getopt_long(argc, argv, short_options,
|
||||
long_options, &option_index);
|
||||
#else
|
||||
opt = getopt(argc, argv, short_options);
|
||||
#endif
|
||||
|
||||
switch(opt)
|
||||
{
|
||||
case -1:
|
||||
// We have finished normally
|
||||
break;
|
||||
case 'n' :
|
||||
// We don't return to main, instead we
|
||||
// initialize the command line version
|
||||
// of sgpemv2 (?)
|
||||
|
||||
// FIXME : to be written!
|
||||
break;
|
||||
case 'h' :
|
||||
default :
|
||||
display_help();
|
||||
}
|
||||
} while( opt != -1 );
|
||||
switch(opt)
|
||||
{
|
||||
case -1:
|
||||
// We have finished normally
|
||||
break;
|
||||
case 'N' :
|
||||
// We don't return to main, instead we
|
||||
// initialize the command line version
|
||||
// of sgpemv2 (?)
|
||||
|
||||
// FIXME : to be written!
|
||||
break;
|
||||
case 'P':
|
||||
GlobalSettings::instance().add_policies_dir(optarg);
|
||||
break;
|
||||
case 'M':
|
||||
GlobalSettings::instance().add_modules_dir(optarg);
|
||||
break;
|
||||
case ':':
|
||||
printf(_("[EE] Wrong number of parameters. Please see \n"
|
||||
"%s --help\n"), argv[0]);
|
||||
exit(-1);
|
||||
case 'h' :
|
||||
default :
|
||||
display_help();
|
||||
}
|
||||
} while( opt != -1 );
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
// Set these two to start from additional filenames on the cmdline:
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
display_help()
|
||||
{
|
||||
printf( _("SGPEMv2 is an educational software acting as a process scheduling simulator\n"
|
||||
"\n\nUsage : sgpemv2 [options]" // filenames"
|
||||
"\n\nOptions:\n"
|
||||
"\t-h, --help this help you're reading\n"
|
||||
"\t-n, --no-gui starts the program in command line mode\n"
|
||||
// "\nFilenames:\n"
|
||||
// "\t a list of any valid SGPEMv2 XML file\n"
|
||||
// "\t to be opened, space-separated.\n"
|
||||
"\nLong options are available only on GNU systems.\n\n" ) );
|
||||
exit(0);
|
||||
printf( _("SGPEMv2 is an educational software acting as a process scheduling simulator\n"
|
||||
"\n\nUsage : sgpemv2 [options]" // filenames"
|
||||
"\n\nOptions:\n"
|
||||
"\t-h, --help this help you're reading\n"
|
||||
"\t-N, --no-gui starts the program in command line mode\n"
|
||||
"\t-P dir, --policies-dir=dir\n"
|
||||
"\t add this directory to the default modules\n"
|
||||
"\t search path\n"
|
||||
"\t-M dir, --modules-dir=dir\n"
|
||||
"\t add this directory to default plugin\n"
|
||||
"\t search path\n"
|
||||
"\nFilenames:\n"
|
||||
"\t a list of any valid SGPEMv2 XML file\n"
|
||||
"\t to be opened, space-separated.\n"
|
||||
"\nLong options are available only on GNU systems.\n\n" ) );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_license()
|
||||
{
|
||||
// Do _NOT_ translate this text.
|
||||
std::cerr <<
|
||||
"SGPEMv2, Copyright (C) 2005, 2006 University of Padova,\n"
|
||||
" dept. of Pure and Applied Mathematics.\n"
|
||||
"SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free \n"
|
||||
"software, and you are welcome to redistribute it under \n"
|
||||
"the terms of the GNU General Public License; for details\n"
|
||||
"see file COPYING contained in the source package. \n"
|
||||
<< std::endl;
|
||||
// Do _NOT_ translate this text.
|
||||
std::cerr <<
|
||||
"SGPEMv2, Copyright (C) 2005, 2006 University of Padova,\n"
|
||||
" dept. of Pure and Applied Mathematics.\n"
|
||||
"SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free \n"
|
||||
"software, and you are welcome to redistribute it under \n"
|
||||
"the terms of the GNU General Public License; for details\n"
|
||||
"see file COPYING contained in the source package. \n"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "backend/pyloader/python_policy_manager.hh"
|
||||
#include "backend/pyloader/python_policy.hh"
|
||||
#include "backend/process.hh"
|
||||
#include "backend/global_settings.hh"
|
||||
#include "backend/schedulable_status.hh"
|
||||
#include "backend/schedulable_list.hh"
|
||||
#include "backend/scheduler.hh"
|
||||
|
@ -36,14 +37,16 @@
|
|||
#include <glibmm/module.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
// FIXME: Eeeeh? Why does this work without explicit namespace resolving?
|
||||
// Is there some using declaration in included HEADERS?? Aaaaagh!
|
||||
|
||||
class TestPythonPolicyManager : public PythonPolicyManager {
|
||||
public:
|
||||
void test_init(const char* policy_name) {
|
||||
init();
|
||||
PyRun_SimpleString("import sys\n"
|
||||
"sys.path[:0] = [ '" MODDIR "', '" POLDIR "' ]\n");
|
||||
_python_policy = std::auto_ptr<PythonPolicy>(new PythonPolicy(policy_name));
|
||||
}
|
||||
};
|
||||
|
@ -52,8 +55,16 @@ public:
|
|||
int
|
||||
main(int argc, char** argv) {
|
||||
using namespace sgpem;
|
||||
using Glib::Module;
|
||||
|
||||
if(argc != 2) {
|
||||
std::cout << "[EE] Usage:\n\t" << argv[0] <<
|
||||
" path/to/uninstalled/policies" << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
// Add current directory to search for uninstalled policies
|
||||
sgpem::GlobalSettings::instance().add_policies_dir(argv[1]);
|
||||
|
||||
Glib::thread_init();
|
||||
|
||||
// Create an INITIAL STATE
|
||||
|
|
Loading…
Reference in New Issue