当前位置: 首页>>代码示例>>Python>>正文


Python data_path.join函数代码示例

本文整理汇总了Python中utils.path.data_path.join函数的典型用法代码示例。如果您正苦于以下问题:Python join函数的具体用法?Python join怎么用?Python join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了join函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_evm_automate_convert

def test_evm_automate_convert(request, rake, ssh_client):
    """This test checks whether conversion from older XML format works.

    Prerequisities:
        * ``data/qe_event_handler.xml`` file.

    Steps:
        * Upload the testing file to the appliance.
        * Convert the file to ZIP using ``evm:automate:convert`` rake task
        * Import the ZIP file using ``evm:automate_import`` rake task.
        * Use ``evm:automate:extract_methods FOLDER=/some_folder`` and verify that a file named
            ``relay_events.rb`` is present in the directory hierarchy.
    """
    ssh_client.put_file(data_path.join("qe_event_handler.xml").strpath, "/root/convert_test.xml")
    request.addfinalizer(lambda: ssh_client.run_command("rm -f /root/convert_test.xml"))
    rc, stdout = rake(
        "evm:automate:convert DOMAIN=Default FILE=/root/convert_test.xml "
        "ZIP_FILE=/root/convert_test.zip")
    request.addfinalizer(lambda: ssh_client.run_command("rm -f /root/convert_test.zip"))
    assert rc == 0, stdout
    rc, stdout = ssh_client.run_command("ls -l /root/convert_test.zip")
    assert rc == 0, stdout
    rc, stdout = rake(
        "evm:automate:import ZIP_FILE=/root/convert_test.zip DOMAIN=Default OVERWRITE=true "
        "PREVIEW=false")
    assert rc == 0, stdout
    # Extract the methods so we can see if it was imported
    rc, stdout = rake("evm:automate:extract_methods FOLDER=/root/automate_methods")
    request.addfinalizer(lambda: ssh_client.run_command("rm -rf /root/automate_methods"))
    assert rc == 0, stdout
    rc, stdout = ssh_client.run_command("find /root/automate_methods | grep 'relay_events[.]rb$'")
    assert rc == 0, "Could not find the method in the extracted methods directory"
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:32,代码来源:test_rake_evm_automate-53.py

示例2: set_yaml_config

def set_yaml_config(config_name, data_dict, hostname=None):
    """Given a yaml name, dictionary and hostname, set the configuration yaml on the server

    The configuration yamls must be inserted into the DB using the ruby console, so this function
    uses SSH, not the database. It makes sense to be included here as a counterpart to
    :py:func:`get_yaml_config`

    Args:
        config_name: Name of the yaml configuration file
        data_dict: Dictionary with data to set/change
        hostname: Hostname/address of the server that we want to set up (default ``None``)

    Note:
        If hostname is set to ``None``, the default server set up for this session will be
        used. See :py:class:``utils.ssh.SSHClient`` for details of the default setup.

    Warning:

        Manually editing the config yamls is potentially dangerous. Furthermore,
        the rails runner doesn't return useful information on the outcome of the
        set request, so errors that arise from the newly loading config file
        will go unreported.

    Usage:

        # Update the appliance name, for example
        vmbd_yaml = get_yaml_config('vmdb')
        vmdb_yaml['server']['name'] = 'EVM IS AWESOME'
        set_yaml_config('vmdb', vmdb_yaml, '1.2.3.4')

    """
    # CFME does a lot of things when loading a configfile, so
    # let their native conf loader handle the job
    # If hostname is defined, connect to the specified server
    if hostname is not None:
        _ssh_client = SSHClient(hostname=hostname)
    # Else, connect to the default one set up for this session
    else:
        _ssh_client = store.current_appliance.ssh_client
    # Build & send new config
    temp_yaml = NamedTemporaryFile()
    dest_yaml = '/tmp/conf.yaml'
    yaml.dump(data_dict, temp_yaml, default_flow_style=False)
    _ssh_client.put_file(temp_yaml.name, dest_yaml)
    # Build and send ruby script
    dest_ruby = '/tmp/load_conf.rb'
    ruby_template = data_path.join('utils', 'cfmedb_load_config.rbt')
    ruby_replacements = {
        'config_name': config_name,
        'config_file': dest_yaml
    }
    temp_ruby = load_data_file(ruby_template.strpath, ruby_replacements)
    _ssh_client.put_file(temp_ruby.name, dest_ruby)

    # Run it
    _ssh_client.run_rails_command(dest_ruby)
    fire('server_details_changed')
    fire('server_config_changed')
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:58,代码来源:db.py

示例3: fix_merkyl_workaround

def fix_merkyl_workaround():
    """Workaround around merkyl not opening an iptables port for communication"""
    ssh_client = SSHClient()
    if ssh_client.run_command('test -f /etc/init.d/merkyl').rc == 0:
        logger.info('Rudely overwriting merkyl init.d on appliance;')
        local_file = data_path.join("bundles").join("merkyl").join("merkyl")
        remote_file = "/etc/init.d/merkyl"
        ssh_client.put_file(local_file.strpath, remote_file)
        ssh_client.run_command("service merkyl restart")
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:9,代码来源:conftest.py

示例4: test_create_snapshot_via_ae

def test_create_snapshot_via_ae(request, domain, test_vm):
    """This test checks whether the vm.create_snapshot works in AE.

    Prerequisities:
        * A VMware provider
        * A VM that has been discovered by CFME

    Steps:
        * Clone the Request class inside the System namespace into a new domain
        * Add a method named ``snapshot`` and insert the provided code there.
        * Add an instance named ``snapshot`` and set the methd from previous step
            as ``meth5``
        * Run the simulation of the method against the VM, preferably setting
            ``snap_name`` to something that can be checked
        * Wait until snapshot with such name appears.
    """
    # PREPARE
    file = data_path.join("ui").join("automate").join("test_create_snapshot_via_ae.rb")
    with file.open("r") as f:
        method_contents = f.read()
    miq_domain = DomainCollection().instantiate(name='ManageIQ')
    miq_class = miq_domain.namespaces.instantiate(name='System').classes.instantiate(name='Request')
    miq_class.copy_to(domain)
    request_cls = domain.namespaces.instantiate(name='System').classes.instantiate(name='Request')
    request.addfinalizer(request_cls.delete)
    method = request_cls.methods.create(name="snapshot", location='inline', script=method_contents)
    request.addfinalizer(method.delete)
    instance = request_cls.instances.create(
        name="snapshot",
        fields={
            "meth5": {
                'value': "snapshot"}})
    request.addfinalizer(instance.delete)

    # SIMULATE
    snap_name = fauxfactory.gen_alpha()
    snapshot = Vm.Snapshot(name=snap_name, parent_vm=test_vm)
    simulate(
        instance="Request",
        request="snapshot",
        target_type='VM and Instance',
        target_object=test_vm.name,
        execute_methods=True,
        attributes_values={"snap_name": snap_name})

    wait_for(lambda: snapshot.exists, timeout="2m", delay=10,
             fail_func=sel.refresh, handle_exception=True)

    # Clean up if it appeared
    snapshot.delete()
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:50,代码来源:test_snapshot.py

示例5: _load_firefox_profile

def _load_firefox_profile():
    # create a firefox profile using the template in data/firefox_profile.js.template
    global firefox_profile_tmpdir
    if firefox_profile_tmpdir is None:
        firefox_profile_tmpdir = mkdtemp(prefix='firefox_profile_')
        # Clean up tempdir at exit
        atexit.register(rmtree, firefox_profile_tmpdir)

    template = data_path.join('firefox_profile.js.template').read()
    profile_json = Template(template).substitute(profile_dir=firefox_profile_tmpdir)
    profile_dict = json.loads(profile_json)

    profile = FirefoxProfile(firefox_profile_tmpdir)
    for pref in profile_dict.iteritems():
        profile.set_preference(*pref)
    profile.update_preferences()
    return profile
开发者ID:sshveta,项目名称:cfme_tests,代码行数:17,代码来源:browser.py

示例6: test_create_snapshot_via_ae

def test_create_snapshot_via_ae(request, domain, test_vm):
    """This test checks whether the vm.create_snapshot works in AE.

    Prerequisities:
        * A VMware provider
        * A VM that has been discovered by CFME

    Steps:
        * Clone the Request class inside the System namespace into a new domain
        * Add a method named ``snapshot`` and insert the provided code there.
        * Add an instance named ``snapshot`` and set the methd from previous step
            as ``meth5``
        * Run the simulation of the method against the VM, preferably setting
            ``snap_name`` to something that can be checked
        * Wait until snapshot with such name appears.
    """
    # PREPARE
    file = data_path.join("ui").join("automate").join("test_create_snapshot_via_ae.rb")
    with file.open("r") as f:
        method_contents = f.read()
    miq_domain = Domain("ManageIQ (Locked)")
    miq_class = Class("Request", namespace=Namespace("System", domain=miq_domain))
    request_cls = miq_class.copy_to(domain)
    request.addfinalizer(request_cls.delete)
    method = Method("snapshot", data=method_contents, cls=request_cls)
    method.create()
    request.addfinalizer(method.delete)
    instance = Instance("snapshot", values={"meth5": "snapshot"}, cls=request_cls)
    instance.create()
    request.addfinalizer(instance.delete)

    # SIMULATE
    snap_name = fauxfactory.gen_alpha()
    snapshot = Vm.Snapshot(name=snap_name, parent_vm=test_vm)
    simulate(
        instance="Request",
        request="snapshot",
        attribute=["VM and Instance", test_vm.name],
        execute_methods=True,
        avp={"snap_name": snap_name},
    )

    wait_for(snapshot.does_snapshot_exist, timeout="2m", delay=10)

    # Clean up if it appeared
    snapshot.delete()
开发者ID:rananda,项目名称:cfme_tests,代码行数:46,代码来源:test_snapshot.py

示例7: _load_firefox_profile

def _load_firefox_profile():
    # create a firefox profile using the template in data/firefox_profile.js.template

    # Make a new firefox profile dir if it's unset or doesn't exist for some reason
    firefox_profile_tmpdir = mkdtemp(prefix='firefox_profile_')
    log.debug("created firefox profile")
    # Clean up tempdir at exit
    atexit.register(rmtree, firefox_profile_tmpdir, ignore_errors=True)

    template = data_path.join('firefox_profile.js.template').read()
    profile_json = Template(template).substitute(profile_dir=firefox_profile_tmpdir)
    profile_dict = json.loads(profile_json)

    profile = FirefoxProfile(firefox_profile_tmpdir)
    for pref in profile_dict.iteritems():
        profile.set_preference(*pref)
    profile.update_preferences()
    return profile
开发者ID:RonnyPfannschmidt,项目名称:cfme_tests,代码行数:18,代码来源:browser.py

示例8: test_evm_automate_convert

def test_evm_automate_convert(request, rake, ssh_client):
    ssh_client.put_file(data_path.join("qe_event_handler.xml").strpath, "/root/convert_test.xml")
    request.addfinalizer(lambda: ssh_client.run_command("rm -f /root/convert_test.xml"))
    rc, stdout = rake(
        "evm:automate:convert DOMAIN=Default FILE=/root/convert_test.xml "
        "ZIP_FILE=/root/convert_test.zip")
    request.addfinalizer(lambda: ssh_client.run_command("rm -f /root/convert_test.zip"))
    assert rc == 0, stdout
    rc, stdout = ssh_client.run_command("ls -l /root/convert_test.zip")
    assert rc == 0, stdout
    rc, stdout = rake(
        "evm:automate:import ZIP_FILE=/root/convert_test.zip DOMAIN=Default OVERWRITE=true "
        "PREVIEW=false")
    assert rc == 0, stdout
    # Extract the methods so we can see if it was imported
    rc, stdout = rake("evm:automate:extract_methods FOLDER=/root/automate_methods")
    request.addfinalizer(lambda: ssh_client.run_command("rm -rf /root/automate_methods"))
    assert rc == 0, stdout
    rc, stdout = ssh_client.run_command("find /root/automate_methods | grep 'relay_events[.]rb$'")
    assert rc == 0, "Could not find the method in the extracted methods directory"
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:20,代码来源:test_rake_evm_automate-53.py

示例9: import_invalid_yaml_file

def import_invalid_yaml_file(request):
    return data_path.join("ui/control/invalid.yaml").realpath().strpath
开发者ID:RonnyPfannschmidt,项目名称:cfme_tests,代码行数:2,代码来源:test_import_policies.py

示例10: import_policy_file

def import_policy_file(request):
    return data_path.join("ui/control/policies.yaml").realpath().strpath
开发者ID:RonnyPfannschmidt,项目名称:cfme_tests,代码行数:2,代码来源:test_import_policies.py

示例11: crud_files_reports

# -*- coding: utf-8 -*-
import pytest
import yaml

from cfme.fixtures import pytest_selenium as sel
from cfme.intelligence.reports.dashboards import Dashboard
from cfme.intelligence.reports.reports import CustomReport
from cfme.intelligence.reports.schedules import Schedule
from cfme.intelligence.reports.widgets import ChartWidget, MenuWidget, ReportWidget, RSSFeedWidget
from utils.path import data_path
from utils.randomness import generate_random_string
from utils.update import update


report_crud_dir = data_path.join("reports_crud")
schedules_crud_dir = data_path.join("schedules_crud")


def crud_files_reports():
    result = []
    if not report_crud_dir.exists():
        report_crud_dir.mkdir()
    for file in report_crud_dir.listdir():
        if file.isfile() and file.basename.endswith(".yaml"):
            result.append(file.basename)
    return result


def crud_files_schedules():
    result = []
    if not schedules_crud_dir.exists():
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:31,代码来源:test_crud.py

示例12: rake

# -*- coding: utf-8 -*-
"""This module contains tests that are supposed to test CFME's CLI functionality."""
import pytest

from cfme.automate.explorer import Domain
from utils.path import data_path
from utils.update import update

cli_path = data_path.join("cli")

pytestmark = [pytest.mark.ignore_stream("5.2")]


@pytest.yield_fixture(scope="function")
def rake(ssh_client):
    ssh_client.run_rake_command("evm:automate:clear")
    ssh_client.run_rake_command("evm:automate:reset")
    yield lambda command: ssh_client.run_rake_command(command)
    # A bit slower but it will at least make it reliable
    ssh_client.run_rake_command("evm:automate:clear")
    ssh_client.run_rake_command("evm:automate:reset")


@pytest.fixture(scope="function")
def qe_ae_data(ssh_client, rake):
    ssh_client.put_file(cli_path.join("QECliTesting.yaml").strpath, "/root/QECliTesting.yaml")
    rc, stdout = rake(
        "evm:automate:import DOMAIN=QECliTesting YAML_FILE=/root/QECliTesting.yaml PREVIEW=false "
        "ENABLED=true")
    assert rc == 0, stdout
    # Now we have to enable the domain to make it work.
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:31,代码来源:test_rake_evm_automate-53.py


注:本文中的utils.path.data_path.join函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。