def single_event_2_criteria(list_of_path, list_of_energy, box_dim):
    """
	this function takes the data of single event, i.e. the configurational data
	and the energy data to check if this event satisfy the stage 1 two criteria
	return True if satisfied, False otherwise
	
	criteria 1:
	the saddle state energy should be larger than the energy of both initial and final state
	exclude the searches E(sad-init) <0 or E(sad - fin) <0
	
	criteria 2:
	If both the energy difference AND distance between the final state and initial state 
	are small, then the final state is identical to the initial state, should be eliminated
	in details, this happens if dE < 0.02 (eV) AND distance < 1
	"""

    init_config = Configuration(list_of_path[0], box_dim)
    fin_config = Configuration(list_of_path[2], box_dim)

    # criteria 1
    if list_of_energy[1] - list_of_energy[0] < 0 or list_of_energy[
            1] - list_of_energy[2] < 0:
        return False

    #criteria 2
    distance = Configuration.distance_pbc(init_config, fin_config)
    if distance < 1 and abs(list_of_energy[2] - list_of_energy[0]) < 0.02:
        return False
    else:
        return True
예제 #2
0
def main():
    globalConfig = Configuration()
    globalConfig.setItem('mode.verbose', False)
    globalConfig.setItem('project.filename', DEFAULT_FILENAME)
    globalConfig.setItem('make.phase', 'build')

    remainingArguments = processArguments(globalConfig)

    if len(remainingArguments) > 0:
        globalConfig.setItem('make.phase', remainingArguments[0])
        remainingArguments = remainingArguments[1:]

    kake(globalConfig, remainingArguments)
예제 #3
0
파일: lyric.py 프로젝트: ChauncyWang/music
    def paintEvent(self, event):
        p1 = 10
        p2 = 20
        if self.single_line:
            self.lyric.setGeometry(p1, p2,
                                   self.width() - 2 * p1,
                                   self.height() - p1 - p2)
            self.lyric.setAlignment(Qt.AlignCenter)
            self.lyric2.hide()
        else:
            w = self.width() - 2 * p1
            h = (self.height() - p1 - p2) / 2
            self.lyric.setGeometry(p1, p2, w, h)
            self.lyric.setAlignment(Qt.AlignLeft)
            self.lyric2.setGeometry(p1, p2 + h, w, h)
            self.lyric2.setAlignment(Qt.AlignRight)
            self.lyric2.show()
        font = QFont()
        font.setPixelSize(self.lyric.height() * 0.8)
        self.lyric.setFont(font)
        self.lyric2.setFont(font)

        if not self.lock:
            if self.enter:
                self.setCursor(Qt.OpenHandCursor)
                painter = QPainter(self)
                path = QPainterPath()
                rect = QRectF(0, 0, self.width(), self.height())
                path.addRoundedRect(rect, 10, 10)
                painter.fillPath(path, QColor(0, 0, 0, 55))
                pen = QPen()
                pen.setWidth(2)
                pen.setColor(QColor(255, 255, 255, 180))
                painter.setPen(pen)
                painter.drawRoundedRect(self.rect(), 10, 10)
                painter.drawRoundedRect(3, 3,
                                        self.width() - 6,
                                        self.height() - 6, 8, 8)

        sgw = self.size_grip.width()
        sgh = self.size_grip.height()
        sw = self.width()
        sh = self.height()
        self.size_grip.setGeometry(sw - sgw - 6, sh - sgh - 6, sgw, sgh)

        Configuration.config['ui']['lyric']['x'] = self.pos().x()
        Configuration.config['ui']['lyric']['y'] = self.pos().y()
        Configuration.config['ui']['lyric']['w'] = self.width()
        Configuration.config['ui']['lyric']['h'] = self.height()
        Configuration.config['ui']['lyric']['single'] = self.single_line
        Configuration.save_config()
예제 #4
0
def kake(globalConfig, remainingArguments):
    makePhase = globalConfig.getItem('make.phase')
    if not isStandardPhase(makePhase):
        reportWrongPhase()

    moduleManager = ModuleManager()

    if isPhaseWithConfig(makePhase):
        projectFilename = globalConfig.getItem('project.filename')
        if existProjectFile(projectFilename) == False:
            reportNoProjectFile()

        projectFile = open(projectFilename)
        projectFileContent = projectFile.read()
        projectFile.close()
        projectConfig = yaml.load(projectFileContent)
        projectConfig['global'] = globalConfig.toDictionary()
        projectConfig['global']['args'] = remainingArguments

        module = moduleManager.getModule(projectConfig['project']['type'])
        moduleAction = moduleManager.getModuleAction(module, makePhase)
        moduleAction(Configuration.fromDictionary(projectConfig))
    elif isPhaseWithoutConfig(makePhase):
        module = moduleManager.getModule(remainingArguments[0])
        moduleAction = moduleManager.getModuleAction(module, makePhase)
        moduleAction()
예제 #5
0
def main():
    #url = 'http://localhost/projects/pyGoose/target.html'
    url = 'http://vietnamnet.vn/vn/van-hoa/84115/xoa-an-cam-bieu-dien-voi-trong-tan-anh-tho.html'
    #url = 'http://www.google.co.in'
    config = Configuration()
    #parsing config as param to crawlcandidate maynot be
    config.contentextractor = StandardContentExtractor
    #config.contentextractor = ContentExtractor
    #config.formatter = LengthbsdFormatter
    config.texthandler = LengthbsdTextHandler
    crawlcandidate = CrawlCandidate(config, url)

    crawler = Crawler(config)
    article = crawler.crawl(crawlcandidate)
    logging.debug(getinnertext(article.topnode, True))
    #logging.debug(getouterhtml(article.topnode))
    print(article.title)
예제 #6
0
파일: testrun.py 프로젝트: vuamitom/pyGoose
def main():
    #url = 'http://localhost/projects/pyGoose/target.html'
    url = 'http://vietnamnet.vn/vn/van-hoa/84115/xoa-an-cam-bieu-dien-voi-trong-tan-anh-tho.html'
    #url = 'http://www.google.co.in'
    config = Configuration()
    #parsing config as param to crawlcandidate maynot be 
    config.contentextractor = StandardContentExtractor
    #config.contentextractor = ContentExtractor
    #config.formatter = LengthbsdFormatter
    config.texthandler = LengthbsdTextHandler
    crawlcandidate = CrawlCandidate(config,url)

    crawler = Crawler(config)
    article = crawler.crawl(crawlcandidate)
    logging.debug(getinnertext(article.topnode, True))
    #logging.debug(getouterhtml(article.topnode))
    print (article.title)
예제 #7
0
def basin_config_distance_activation_energy(path_to_test_dir, event_state):
	"""
	each test is corresponding to the triggering of a single atom, which search the
	potential energy trajectory around that basin of that atom located
	
	event_state is a list of ordered states (corresponding to their appearance order), 
	each event state contains the strings of all states, init_state, sad_state, fin_state, 
	with intermediate states that can be obtained from ART output
	
	Input:
		
		event_state: a list
			a list of strs with each str being an state, e,g min1000
	
	Returns:
	
		config_distance: a list
			a list of distances from current state to the initial state
		
		eng_barrier: a list
			a list of energy barriers from current state to the initial state
	"""
	i=0
	config_distance, eng_barrier = []
	for state in event_state:
		
		if i == 0:
			init = state
			path_to_init_file = path_to_test_dir + '/' + init + ".dump"
			init_config = Configuration(path_to_init_file)
			config_distance.append(0)
			eng_barrier.append(0)
		else:
			path_to_state_file = path_to_test_dir + '/' + state + ".dump"
			
			state_config = Configuration(path_to_state_file)
			
			state_act_eng = state_energy_barrier(path_to_test_dir, init, state)
			
			state_distance = Configuration.distance_pbc(state_config, init_config)
			
			config_distance.append(state_distance)
			
			eng_barrier.append(state_act_eng)
	return (config_distance, eng_barrier)
예제 #8
0
파일: lyric.py 프로젝트: ChauncyWang/music
 def init(self):
     Configuration.load_config()
     configuration = Configuration.config
     x = Configuration.get(100, 'ui', 'lyric', 'x')
     y = Configuration.get(800, 'ui', 'lyric', 'y')
     w = Configuration.get(400, 'ui', 'lyric', 'w')
     h = Configuration.get(80, 'ui', 'lyric', 'h')
     self.single_line = Configuration.get(False, 'ui', 'lyric', 'single')
     self.setGeometry(x, y, w, h)
     self.setObjectName('lyric_bar')
     self.setWindowFlags(Qt.SubWindow | Qt.FramelessWindowHint
                         | Qt.WindowStaysOnTopHint)
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     self.setMouseTracking(True)
     self.lyric.setObjectName('lyric')
     self.lyric2.setObjectName('lyric2')
     self.lyric2.hide()
예제 #9
0
    def build(self, projectConfig):
        for project in self.projects:
            projectFilename = globalConfig.getItem('project.filename')
            if existProjectFile(projectFilename) == False:
                reportNoProjectFile()

            projectFile = open(projectFilename)
            projectFileContent = projectFile.read()
            projectFile.close()
            projectConfig = yaml.load(projectFileContent)
            projectConfig['global'] = globalConfig.toDictionary()
            projectConfig['global']['args'] = remainingArguments

            module = moduleManager.getModule(projectConfig['project']['type'])
            moduleAction = moduleManager.getModuleAction(module, makePhase)
            moduleAction(Configuration.fromDictionary(projectConfig))

        returnValue = 0
        if returnValue == 0:
            return True
        else:
            return False
    def build(self, projectConfig):
        for project in self.projects:
            projectFilename = globalConfig.getItem('project.filename')
            if existProjectFile(projectFilename) == False:
                reportNoProjectFile()

            projectFile = open(projectFilename)
            projectFileContent = projectFile.read()
            projectFile.close()
            projectConfig = yaml.load(projectFileContent)
            projectConfig['global'] = globalConfig.toDictionary()
            projectConfig['global']['args'] = remainingArguments

            module = moduleManager.getModule(projectConfig['project']['type'])
            moduleAction = moduleManager.getModuleAction(module, makePhase)
            moduleAction(Configuration.fromDictionary(projectConfig))
            

        returnValue = 0
        if returnValue == 0:
            return True
        else:
            return False
예제 #11
0
def pushOne(configurator: util.Configuration, config: dict, arguments: argparse.Namespace, configure_all: bool):
    """
    Fonction pour Thread.
    Elle permet de pousser via Telnet un configuration sur un routeur cisco.
    Cette configuration se fait à l'aide d'un fichier json.
    :param configurator: Objet Configuration du fichier util.py
    :param config: Dictionnaire du fichier de configuration json
    :param arguments: Liste d'arguments de argparse
    :param configure_all: Boolean pour la configuration de multiple protocole ou pour "l'effacement" de la configuration
    :return: None
    """
    # Erase running configuration
    if arguments.erase:
        configurator.eraseRunningConfiguration()
        return

    # Enter in router
    configurator.globalConfigMode()

    # Change hostname
    configurator.changeHostname()

    # Activated IPv6
    configurator.activeIPv6()

    # VRF
    if "VRF" in config:
        if arguments.vrf or configure_all:
            for vrf in config["VRF"]:
                configurator.setVRF(vrf["name"],
                                    vrf["rd"],
                                    vrf["rt_import"],
                                    vrf["rt_export"])

                configurator.setVRFonOSPF(vrf["name"],
                                          vrf["ospf_prosses"],
                                          vrf["network"],
                                          vrf["ospf_area"],
                                          config["BGP"]["AS"])

                configurator.activateVRFonBGP(config["BGP"]["AS"],
                                              vrf["name"],
                                              vrf["ospf_prosses"])
            for interface in config["interfaces"]:
                if "VRF" in interface:
                    configurator.activateVRFonInterface(interface["interfaceName"],
                                                        interface["VRF"])

    # Interface
    for interface in config["interfaces"]:
        if arguments.interface and arguments.interface != "all":
            if interface["interfaceName"] != arguments.interface:
                continue
        if "IPv4" in interface:
            configurator.setUpIPv4(interface["interfaceName"],
                                   interface["IPv4"])

        if "IPv6" in interface:
            configurator.setUpIPv6(interface["interfaceName"],
                                   interface["IPv6"])
        if "description" in interface:
            configurator.setIntDescription(interface["interfaceName"],
                                           interface["description"])

    # OSPF
    if arguments.ospf or configure_all:
        # Set OSPF
        if "OSPF_id" in config:
            configurator.setOSPFv2(config["OSPF_id"])
            configurator.setOSPFv3(config["OSPF_id"])

        # Set OSPF neighbour
        if "OSPF_neighbour" in config:
            configurator.setNeighbourOSPFv2(config["OSPF_neighbour"])

        for interface in config["interfaces"]:
            if "OSPF_area" in interface and interface["OSPF_area"]:
                configurator.activeOSPFv3Interface(interface["interfaceName"],
                                                   interface["OSPF_area"])

    # BGP
    if "BGP" in config:
        BGP_conf = config["BGP"]
        configurator.setMPBGPneighborIPv4(BGP_conf["AS"],
                                          BGP_conf["neighbor"])
        configurator.activateVPNonBGP(BGP_conf["AS"],
                                      BGP_conf["neighbor"])

    # MPLS
    if arguments.mpls or configure_all:
        # Activated MPLS
        if "ipcef" in config:
            configurator.activeIPcef()
        for interface in config["interfaces"]:
            if "MPLS" in interface:
                if interface["MPLS"]:
                    configurator.activeMPLSonInterface(interface["interfaceName"])
예제 #12
0
import os
import sys
import logging

sys.path.append(
    os.path.realpath(os.path.abspath("%s/../" % os.path.dirname(__file__))))
from util import call, RunCommandError, Configuration

from size_helper import size_parser, size_human_readable

logger = logging.getLogger(__name__)
config = Configuration('dum.cfg')


class DirHunter(object):
    """ Hunting those large directories, whose size over the specified
    """
    def __init__(self, mount_point):
        self._mount = mount_point
        self._maxsize = self._get_maxsize()

    def _get_maxsize(self):
        try:
            return size_parser(config.common.maxsize)
        except ValueError as err:
            logger.error("Parse size error: %s" % err)
            ### give a default size: 1G
            return 1024 * 1024 * 1024

    def gen_summary(self):
        summary = 'Summary of %s:\n' % self._mount
예제 #13
0
import json, math, uuid
from flask import *
from service.ProductService import *
from util.Configuration import *

product = Blueprint('product', __name__)

pageSize = Configuration().get("PageSize")


# 产品列表
@product.route("index", methods=["get"])
def index():
    productService = ProductService()

    currentIndex = request.args.get("page")
    if currentIndex is None:
        return ("forbidden", 403)

    lastIndex = math.ceil(productService.count() / float(pageSize))

    products = productService.list(int(currentIndex) - 1, pageSize)

    result = []
    for product in products:
        result.append(product.dicted())

    result = json.dumps({
        "currentIndex": currentIndex,
        "lastIndex": lastIndex,
        "products": result
예제 #14
0
def getConnection():
    return sqlite3.connect(Configuration().get("DatabaseCWD"))