Пример #1
0
	def get_virtual_page(self, root, suffix):
		fullpath = utils.pjoin(root.path, suffix)
		if fullpath in self.pcache and \
		   isinstance(self.pcache[fullpath], pages.VirtDir):
			return self.pcache[fullpath]
		sl = suffix.split("/")
		for i in range(0, len(sl)):
			fp = utils.pjoin(root.path, '/'.join(sl[:i+1]))
			res = pages.VirtDir(fp, self, root)
			self.pcache[fp] = res
		return self.pcache[fullpath]
Пример #2
0
def upload_project_configuration():
    source_file = pjoin(cget(u'deploy_files'), u'gunicorn',
                        'gunicorn_start')
    target_file = pjoin(cget(u'project_dir'), u'bin',
                        u'gunicorn_start')

    print yellow('Uploading gunicorn starting script')
    upload_template(source_file, target_file, config)
    print yellow('Upload done!')

    with cd(cget('project_dir')):
        run('mkdir -p run')
        run('chmod u+x bin/gunicorn_start')
        print yellow('Starting gunicorn!')
        run('./bin/gunicorn_start')
Пример #3
0
def started():
	code_dir = pjoin(cget('project_dir'), 'code')
	with cd(code_dir):
		code_branch = cget('branch', 'master')
		run('git clean -f')
		run('git fetch origin')
		run('git reset --hard origin/{}'.format(code_branch))
Пример #4
0
	def disallows_view(self, dpage, view):
		dpage = dpage.me()
		if dpage.type != "dir":
			return False
		flagn = ".flag.noview:" + view
		fpath = utils.pjoin(dpage.path, flagn)
		return self.pstore.exists(fpath)
 def setUp(self):
   template_path = pjoin(
       self.test_context.engine_directory, "recommendation-engine")
   app_context = AppContext(
       name="MyRecommender",
       template=template_path)
   self.app = AppEngine(self.test_context, app_context)
Пример #6
0
def upload_project_configuration():
	source_file = pjoin(cget('deploy_files'), 'nginx',
						 'project.conf')
	target_file = pjoin(cget('services_dir'), 'nginx',
						'sites-available', cget('nginx_server_name'))

	# make sure that there is such directory
	run('mkdir -p {}'.format(pjoin(cget('services_dir'), 'nginx',
								   'sites-available')))
	run('mkdir -p {}'.format(pjoin(cget('project_dir'), 'logs')))
	
	print yellow('Uploading site configuration.')
	upload_template(source_file, target_file, config)

	print yellow('Testing configuration...')
	# test nginx congiguration
	# I wonder if using just sudo wouldn't be better here...
	run('sudo nginx -t')
Пример #7
0
	def get_alias_page(self, pname):
		if "alias-path" not in self.cfg:
			return None
		npath = utils.pjoin(self.cfg["alias-path"], pname)
		res = self.get_page(npath)
		if not res.exists():
			return None
		else:
			return res
Пример #8
0
	def children(self, whattype = None):
		if self.type != "dir":
			return []
		if whattype:
			# Worth optimizing, since the common case is
			# whattype == "dir" and in a large directory
			# of blog entries we'd otherwise unnecessarily
			# set up a lot of file pages.
			pathlist = [utils.pjoin(self.path, z)
				    for z in self.pfile.contents()]
			clist = [self._get(x) for x in pathlist if
				 self.model.pstore.get_type(x) == whattype]
			return clist

		# no whattype
		clist = [self._get(utils.pjoin(self.path, z)) for
			 z in self.pfile.contents()]
		if whattype:
			clist = [z for z in clist if z.type == whattype]
		return clist
Пример #9
0
    def setUp(self):
        self.log.info("Setting up the engine")

        template_path = pjoin(self.test_context.engine_directory,
                              "recommendation-engine")
        engine_json_path = pjoin(self.test_context.data_directory,
                                 "quickstart_test/engine.json")

        self.training_data_path = pjoin(self.test_context.data_directory,
                                        "quickstart_test/training_data.txt")

        # downloading training data
        srun('curl https://raw.githubusercontent.com/apache/spark/master/' \
                'data/mllib/sample_movielens_data.txt --create-dirs -o {}'
                .format(self.training_data_path))

        app_context = AppContext(name="MyRecommender",
                                 template=template_path,
                                 engine_json_path=engine_json_path)

        self.app = AppEngine(self.test_context, app_context)
Пример #10
0
	def pref_view_and_dir(self, dpage, views):
		if dpage.type != "dir":
			return (None, None)
		for cp in utils.walk_to_root(dpage.me()):
			for posview in views:
				if posview == 'index' and cp != dpage:
					continue
				flagn = ".flag.prefview:" + posview
				fpath = utils.pjoin(cp.path, flagn)
				if self.pstore.exists(fpath):
					return (posview, cp)
		return (None, None)
Пример #11
0
	def get_comment(self, page, comment):
		if not self.comments_on():
			return None
		if page.type != 'file' or not page.displayable():
			return None
		compath = utils.pjoin(page.path, comment)
		po = self._commentpage(compath)
		if not po or po.type != "file" or not po.displayable():
			raise derrors.IntErr("missing or undisplayable comment '%s' on page '%s'" % (comment, page))
		c = model_comment.loadcomment(po, comment)
		if c is None:
			raise derrors.IntErr("misformatted comment '%s' on '%s'" % (comment, page.path))
		return c
  def setUp(self):
    self.log.info("Setting up the engine")

    template_path = pjoin(
        self.test_context.engine_directory, "recommendation-engine")
    engine_json_path = pjoin(
        self.test_context.data_directory, "quickstart_test/engine.json")

    self.training_data_path = pjoin(
        self.test_context.data_directory,
        "quickstart_test/training_data.txt")

    # downloading training data
    srun('curl https://raw.githubusercontent.com/apache/spark/master/' \
            'data/mllib/sample_movielens_data.txt --create-dirs -o {}'
            .format(self.training_data_path))

    app_context = AppContext(
        name="MyRecommender",
        template=template_path,
        engine_json_path=engine_json_path)

    self.app = AppEngine(self.test_context, app_context)
 def load_events(self, json_file):
   file_path = pjoin(self.test_context.data_directory,
       'eventserver_test/{}'.format(json_file))
   return json.loads(open(file_path).read())
 def setUp(self):
     template_path = pjoin(self.test_context.engine_directory,
                           "recommendation-engine")
     app_context = AppContext(name="MyRecommender", template=template_path)
     self.app = AppEngine(self.test_context, app_context)
 def load_events(self, json_file):
     file_path = pjoin(self.test_context.data_directory,
                       'eventserver_test/{}'.format(json_file))
     return json.loads(open(file_path).read())
Пример #16
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on Aug 9, 2013

@author: Chunwei Yan @ pkusz
@mail:  [email protected]
'''
from __future__ import division

import os
from utils import pjoin

PROJECT_PATH = os.path.dirname(__file__)
DATA_PATH = pjoin(PROJECT_PATH, 'data')

LABELED_DATA_PATH = pjoin(DATA_PATH, 'train4user_with_label.txt')

DB_PATH = pjoin(DATA_PATH, 'database.bdb')

# charater-wise 编辑距离
CHA_EDIT_DIS_PH = pjoin(DATA_PATH, 'cha_edit_dis.txt')
# word-wise 编辑距离
WORDID_EDIT_DIS_PH = pjoin(DATA_PATH, 'wordid_edit_dis.txt')

# 用于源title分词
SOURCE_TITLES_PH = pjoin(DATA_PATH, 'source_titles.txt')
TARGET_TITLES_PH = pjoin(DATA_PATH, 'target_titles.txt')
# word splited files
SPLITED_SOURCE_TITLES_PH = pjoin(DATA_PATH, 'source_titles.txt_split')
SPLITED_TARGET_TITLES_PH = pjoin(DATA_PATH, 'target_titles.txt_split')
Пример #17
0
	def child(self, name):
		return self._get(utils.pjoin(self.path, name))