Ejemplo n.º 1
0
def model_init(paramfile = "parameters.py", outdir = "output", in_batch = False, batch_no = 0, default_random = False, seed_file = None):
    Runinfo.param_file_path = paramfile
    Runinfo.out_dir_path = outdir
    Runinfo.in_batch = in_batch
    Runinfo.batch_no = batch_no


    with open(paramfile, 'r') as params_file:
	Runinfo.params_file_text = params_file.read()

    try:
        if outdir != None:
	    os.mkdir(Runinfo.out_dir_path)
    except OSError:
	pass

    if outdir != None:
	with open(os.path.join(outdir, 'parameters.py'), 'w') as params_out_file:
	    params_out_file.write(Runinfo.params_file_text)

    distr_init(seed_file, fast = default_random)
    if outdir != None:
	save_run(os.path.join(outdir, 'initial'))
	
	import cPickle as pickle
	import platform
	import subprocess
	import sys

	d = {
	'argv[0]':		sys.argv[0],
	'argv':			' '.join(sys.argv),
	'cwd':			os.getcwd(),
	'hostname':		platform.node(),
	'version':		platform.python_version(),
	'implementation':	platform.python_implementation(),
	'svnversion':		'NONE', #subprocess.check_output('svnversion .', shell=True)
	}
	with open(os.path.join(outdir, 'info'), 'w') as f:
	    pickle.dump(d, f)
	import pprint
	pprint.pprint(d)
	
	

    Parameters()
    print Parameters.default
    import saveableparams
    saveableparams.parameters = Parameters.default

    if in_batch:
	Parameters.default.load_batch_mode(batch_no, paramfile)
    else:
	Parameters.default.load_from_file(paramfile)

    print str(saveableparams.parameters)

    from environment import Environment
    Runinfo.environment = Environment()

    import signals
    signals.setup()

    import listeners

    if outdir != None:
	listeners.setup_listeners()

    def save_params_for_viewer():
	with open(os.path.join(outdir, 'params.txt'), 'w') as f:
	    f.write(saveableparams.parameters.initstr)

    if outdir != None:
	atexit.register(save_params_for_viewer)
Ejemplo n.º 2
0
    location = models.CharField(max_length=1000, default='')
    website = models.CharField(max_length=1000, default='')
    bio = models.CharField(max_length=1000, default='')

    confirmed = models.BooleanField(default=False)

    def get_following_history(self, history=None):
        following = self.follows.all()
        if not history:

            from api.models import EyeHistory
            history = EyeHistory.objects.all()

        query_set = history.filter(user__in=following)
        return query_set

    def get_full_name(self):
        fullname = self.user.get_full_name()
        if fullname:
            return fullname
        return self.user.username

    def __unicode__(self):
        return "%s's profile" % self.user


User.profile = property(lambda u: u.get_profile())

import signals
signals.setup()
Ejemplo n.º 3
0
    anon_email = models.BooleanField(default=False)

    location = models.CharField(max_length=1000, default='')
    website = models.CharField(max_length=1000, default='')
    bio = models.CharField(max_length=1000, default='')

    confirmed = models.BooleanField(default=False)

    def get_following_history(self, history=None):
        following = self.follows.all()
        if not history:
            history = EyeHistory.objects.all()

        query_set = history.filter(user__in=following)
        return query_set

    def get_full_name(self):
        fullname = self.user.get_full_name()
        if fullname:
            return fullname
        return self.user.username

    def __unicode__(self):
        return "%s's profile" % self.user


User.profile = property(lambda u: u.get_profile())

import signals
signals.setup()
Ejemplo n.º 4
0
 def ready(self):
     import signals
     signals.setup()