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


Python rhnSQL.prepare函数代码示例

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


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

示例1: _process_testresult

def _process_testresult(tr, server_id, action_id, benchmark, profile, errors):
    start_time = None
    if tr.hasAttribute("start-time"):
        start_time = tr.getAttribute("start-time")

    h = rhnSQL.prepare(_query_insert_tresult, blob_map={"errors": "errors"})
    h.execute(
        server_id=server_id,
        action_id=action_id,
        bench_id=_truncate(benchmark.getAttribute("id"), 120),
        bench_version=_truncate(benchmark.getAttribute("version"), 80),
        profile_id=profile.getAttribute("id"),
        profile_title=_truncate(profile.getAttribute("title"), 120),
        identifier=_truncate(tr.getAttribute("id"), 120),
        start_time=start_time.replace("T", " "),
        end_time=tr.getAttribute("end-time").replace("T", " "),
        errors=errors,
    )
    h = rhnSQL.prepare(_query_get_tresult)
    h.execute(server_id=server_id, action_id=action_id)
    testresult_id = h.fetchone()[0]
    if not _process_ruleresults(testresult_id, tr):
        h = rhnSQL.prepare(_query_update_errors, blob_map={"errors": "errors"})
        h.execute(
            testresult_id=testresult_id,
            errors=errors + "\nSome text strings were truncated when saving to the database.",
        )
开发者ID:kidaa30,项目名称:spacewalk,代码行数:27,代码来源:scap.py

示例2: test_executemany

    def test_executemany(self):
        """
        Tests the case of passing an integer as a value into a VARCHAR2 column
        (executemany makes it more interesting because the driver generally
        verifies the param types; passing a string and an Int takes it one
        step further)
        """
        h = rhnSQL.prepare(
            """
            insert into %s (id, val) values (:id, :val)
        """
            % self.table_name
        )
        params = {"id": [1, 2], "val": ["", 3]}
        apply(h.executemany, (), params)

        h = rhnSQL.prepare("select id, val from %s" % self.table_name)
        h.execute()
        rows = h.fetchall_dict()
        self.assertEqual(len(rows), 2)
        v_id, v_val = rows[0]["id"], rows[0]["val"]
        self.assertEqual(v_id, 1)
        self.assertEqual(v_val, None)
        v_id, v_val = rows[1]["id"], rows[1]["val"]
        self.assertEqual(v_id, 2)
        self.assertEqual(v_val, "3")
开发者ID:pombredanne,项目名称:spacewalk-1,代码行数:26,代码来源:test_executemany.py

示例3: _register_dispatcher

 def _register_dispatcher(self, jabber_id, hostname, port):
     h = rhnSQL.prepare(self._query_update_register_dispatcher)
     rowcount = h.execute(jabber_id_in=jabber_id, hostname_in=hostname, port_in=port, password_in=self._password)
     if not rowcount:
         h = rhnSQL.prepare(self._query_insert_register_dispatcher)
         h.execute(jabber_id_in=jabber_id, hostname_in=hostname, port_in=port, password_in=self._password)
     rhnSQL.commit()
开发者ID:mantel,项目名称:spacewalk,代码行数:7,代码来源:osa_dispatcher.py

示例4: client_set_namespaces

    def client_set_namespaces(self, systemid, namespaces):
        self.auth_system(systemid)

        server_id = self.server.getid()
        org_id = self.server.server['org_id']

        h = rhnSQL.prepare("""
            delete from rhnServerConfigChannel where server_id = :server_id
        """)
        h.execute(server_id=server_id)

        h = rhnSQL.prepare("""
            insert into rhnServerConfigChannel (server_id, config_channel_id, position)
            select :server_id, id, :position
              from rhnConfigChannel
             where name = :config_channel
               and org_id = :org_id
        """)

        position = 0
        for config_channel in namespaces:
            rowcount = h.execute(server_id=server_id, position=position,
                                 config_channel=config_channel, org_id=org_id)
            if not rowcount:
                raise rhnFault(4009, "Unable to find config channel %s" %
                               config_channel, explain=0)
            position = position + 1

        rhnSQL.commit()
        return 0
开发者ID:dewayneHat,项目名称:spacewalk,代码行数:30,代码来源:rhn_config_management.py

示例5: _delete_rpm_group

def _delete_rpm_group(packageIds):

    references = [
        'rhnChannelPackage',
        'rhnErrataPackage',
        'rhnErrataPackageTMP',
        'rhnPackageChangelogRec',
        'rhnPackageConflicts',
        'rhnPackageFile',
        'rhnPackageObsoletes',
        'rhnPackageProvides',
        'rhnPackageRequires',
        'rhnPackageRecommends',
        'rhnPackageSuggests',
        'rhnPackageSupplements',
        'rhnPackageEnhances',
        'rhnPackageBreaks',
        'rhnPackagePredepends',
        'rhnServerNeededCache',
    ]
    deleteStatement = "delete from %s where package_id = :package_id"
    for table in references:
        h = rhnSQL.prepare(deleteStatement % table)
        count = h.executemany(package_id=packageIds)
        log_debug(3, "Deleted from %s: %d rows" % (table, count))
    deleteStatement = "delete from rhnPackage where id = :package_id"
    h = rhnSQL.prepare(deleteStatement)
    count = h.executemany(package_id=packageIds)
    if count:
        log_debug(2, "DELETED package id %s" % str(packageIds))
    else:
        log_error("No such package id %s" % str(packageIds))
    rhnSQL.commit()
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:33,代码来源:contentRemove.py

示例6: find_or_create_channel_arch

def find_or_create_channel_arch(name, label):
    lookup = """
       SELECT id from rhnChannelArch
        WHERE label='%s' AND name = '%s'
    """ % (label, name)
    h = rhnSQL.prepare(lookup)
    h.execute()
    row = h.fetchone_dict()
    if row:
        return row['id']

    query_create = """
       INSERT INTO  rhnChannelArch
              (id, arch_type_id, label, name)
       VALUES (sequence_nextval('rhn_channel_arch_id_seq'), :arch_type_id, :label, :name)

    """
    arch_type_id = find_or_create_arch_type(name = name, label = label)
    h = rhnSQL.prepare(query_create)
    try:
        h.execute(
            arch_type_id = arch_type_id,
            label        = label,
            name         = name
        )
        rhnSQL.commit()
    except rhnSQL.SQLError, e:
        # if we're here that means we're voilating something
        raise
开发者ID:Kilian-Petsch,项目名称:spacewalk,代码行数:29,代码来源:misc_functions.py

示例7: _update_package_data

    def _update_package_data(self, crash_id, pkg_data):
        log_debug(1, "_update_package_data: %s, %s" % (crash_id, pkg_data))
        # Older versions of abrt used to store the package info in a single 'package' file
        if pkg_data and 'package' in pkg_data:
            (n, e, v, r) = parseRPMName(pkg_data['package'])
            if not all((n, e, v, r)):
                return 0

            h = rhnSQL.prepare(_query_update_pkg_data1)
            r = h.execute(
                crash_id=crash_id,
                pkg_name=n,
                pkg_epoch=e,
                pkg_version=v,
                pkg_release=r)
            rhnSQL.commit()

            return r

        for item in ['pkg_name', 'pkg_epoch', 'pkg_version', 'pkg_release', 'pkg_arch']:
            if not (item in pkg_data and pkg_data[item]):
                return 0

        h = rhnSQL.prepare(_query_update_pkg_data2)
        r = h.execute(
            crash_id=crash_id,
            pkg_name=pkg_data['pkg_name'],
            pkg_epoch=pkg_data['pkg_epoch'],
            pkg_version=pkg_data['pkg_version'],
            pkg_release=pkg_data['pkg_release'],
            pkg_arch=pkg_data['pkg_arch'])
        rhnSQL.commit()

        return r
开发者ID:dewayneHat,项目名称:spacewalk,代码行数:34,代码来源:abrt.py

示例8: load_suse_products

 def load_suse_products(self):
     log_debug(1, "load suse_products")
     if not self.server['id']:
         return
     h = rhnSQL.prepare("""
             SELECT s.guid,
                    s.secret,
                    ost.target ostarget
               FROM suseServer s
          LEFT JOIN suseOsTarget ost ON s.ostarget_id = ost.id
              WHERE s.rhn_server_id = :server_id
     """)
     h.execute(server_id = self.server['id'])
     self.suse_products = h.fetchone_dict() or {}
     if len(self.suse_products) > 0:
         h = rhnSQL.prepare("""
         SELECT sip.name,
                sip.version,
                sip.release,
                rpa.label arch,
                sip.is_baseproduct baseproduct
           FROM suseInstalledProduct sip
            JOIN rhnPackageArch rpa ON sip.arch_type_id = rpa.id
            JOIN suseServerInstalledProduct ssip ON sip.id = ssip.suse_installed_product_id
          WHERE ssip.rhn_server_id = :server_id
         """)
         h.execute(server_id = self.server['id'])
         self.suse_products['products'] = h.fetchall_dict() or []
开发者ID:m47ik,项目名称:uyuni,代码行数:28,代码来源:server_suse.py

示例9: create_first_private_chan_family

def create_first_private_chan_family():
    """
    Check to see if org has a channelfamily associated with it.
    If not, Create one.
    """
    _lookup_chfam = """
       SELECT 1 from rhnChannelFamily
        WHERE label='private-channel-family-1'
    """
    h = rhnSQL.prepare(_lookup_chfam)
    row = h.execute()
    # some extra check for upgrades
    if row:
        # Already exists, move on
        return
    _query_create_chfam = """
       INSERT INTO  rhnChannelFamily
              (id, name, label, org_id, product_url)
       VALUES (sequence_nextval('rhn_channel_family_id_seq'), :name, :label, :org, :url)

    """
    h = rhnSQL.prepare(_query_create_chfam)
    try:
        h.execute(name='Private Channel Family 1', \
                  label='private-channel-family-1', \
                  org=1, url='First Org Created')
    except rhnSQL.SQLError, e:
        # if we're here that means we're voilating something
        raise
开发者ID:T-D-Oe,项目名称:spacewalk,代码行数:29,代码来源:satCerts.py

示例10: delete_guests

def delete_guests(server_id):
    """
    Callback used after a successful kickstart to remove any guest virtual
    instances, as well as their associated servers.
    """
    # First delete all the guest server objects:
    h = rhnSQL.prepare(_query_lookup_guests_for_host)
    h.execute(server_id=server_id)
    delete_server = rhnSQL.Procedure("delete_server")
    log_debug(4, "Deleting guests")
    while 1:
        row = h.fetchone_dict()
        if not row:
            break
        guest_id = row['virtual_system_id']
        log_debug(4, 'Deleting guest server: %s' % guest_id)
        try:
            if guest_id is not None:
                delete_server(guest_id)
        except rhnSQL.SQLError:
            log_error("Error deleting server: %s" % guest_id)

    # Finally delete all the virtual instances:
    log_debug(4, "Deleting all virtual instances for host")
    h = rhnSQL.prepare(_query_delete_virtual_instances)
    h.execute(server_id=server_id)

    # Commit all changes:
    try:
        rhnSQL.commit()
    except rhnSQL.SQLError:
        e = sys.exc_info()[1]
        log_error("Error committing transaction: %s" % e)
        rhnSQL.rollback()
开发者ID:m47ik,项目名称:uyuni,代码行数:34,代码来源:server_kickstart.py

示例11: _push_config_file

    def _push_config_file(self, file):
        config_info_query = self._query_lookup_non_symlink_config_info
        if self._is_link(file) and file.get("symlink"):
            config_info_query = self._query_lookup_symlink_config_info

        # Look up the config info first
        h = rhnSQL.prepare(config_info_query)
        h.execute(**file)
        row = h.fetchone_dict()
        if not row:
            # Hmm
            raise rhnException("This query should always return a row")
        config_info_id = row['id']
        file['config_info_id'] = config_info_id

        # Look up the config file itself
        h = rhnSQL.prepare(self._query_lookup_config_file)
        h.execute(**file)
        row = h.fetchone_dict()
        if row:
            # Yay we already have this file
            # Later down the road, we're going to update modified for this
            # table
            file['config_file_id'] = row['id']
            return

        # Have to insert this config file, gotta use the api to keep quotas up2date...
        insert_call = rhnSQL.Function("rhn_config.insert_file",
                                      rhnSQL.types.NUMBER())
        file['config_file_id'] = insert_call(file['config_channel_id'], file['path'])
开发者ID:TJM,项目名称:spacewalk,代码行数:30,代码来源:configFilesHandler.py

示例12: cleanup_profile

def cleanup_profile(server_id, action_id, ks_session_id, action_status):
    if ks_session_id is None:
        log_debug(4, "No kickstart session")
        return
    if action_status != 2:
        log_debug(4, "Action status: %s; nothing to do" % action_status)
        return

    h = rhnSQL.prepare(_query_lookup_ks_server_profile)
    h.execute(ks_session_id=ks_session_id, profile_type_label='sync_profile')
    row = h.fetchone_dict()
    if not row:
        log_debug(4, "No server profile of the right type found; nothing to do")
        return

    server_profile_id = row['server_profile_id']
    if server_profile_id is None:
        log_debug(4, "No server profile associated with this kickstart session")
        return

    # There is an "on delete cascade" constraint on
    # rhnKickstartSession.server_profile_id and on
    # rhnServerProfilePacakge.server_profile_id
    h = rhnSQL.prepare(_query_delete_server_profile)
    h.execute(server_profile_id=server_profile_id)
开发者ID:m47ik,项目名称:uyuni,代码行数:25,代码来源:server_kickstart.py

示例13: schedule_kickstart_delta

def schedule_kickstart_delta(server_id, kickstart_session_id,
                             installs, removes):
    log_debug(3, server_id, kickstart_session_id)
    row = get_kickstart_session_info(kickstart_session_id, server_id)
    org_id = row['org_id']
    scheduler = row['scheduler']

    action_id = rhnAction.schedule_server_action(
        server_id,
        action_type='packages.runTransaction', action_name="Package delta",
        delta_time=0, scheduler=scheduler, org_id=org_id,
    )

    package_delta_id = rhnSQL.Sequence('rhn_packagedelta_id_seq').next()

    h = rhnSQL.prepare(_query_insert_package_delta)
    h.execute(package_delta_id=package_delta_id)

    h = rhnSQL.prepare(_query_insert_action_package_delta)
    h.execute(action_id=action_id, package_delta_id=package_delta_id)

    h = rhnSQL.prepare(_query_insert_package_delta_element)
    col_names = ['n', 'v', 'r', 'e']
    __execute_many(h, installs, col_names, operation='insert', a=None,
                   package_delta_id=package_delta_id)
    __execute_many(h, removes, col_names, operation='delete', a=None,
                   package_delta_id=package_delta_id)

    update_ks_session_table(kickstart_session_id, 'package_synch_scheduled',
                            action_id, server_id)

    return action_id
开发者ID:m47ik,项目名称:uyuni,代码行数:32,代码来源:server_kickstart.py

示例14: mtime_upload

def mtime_upload(server_id, action_id, data={}):
    # at this point in time, no rhnActionConfigFileName entries exist, because
    # we didn't know them at schedule time...  go ahead and create them now, and then
    # just use the main upload to handle the updating of the state...
    paths = data.get('attempted_paths') or []

    if not paths:
        log_debug(6, "no matched files")
        return

    log_debug(6, 'attempted paths', paths)

    # if there are already rhnActionConfigFileName entries for this sid+aid,
    # it's most likely a rescheduled action, and we'll need to blow away the old
    # entries (they might not be valid any longer)
    h = rhnSQL.prepare(_query_any_action_config_filenames)
    h.execute(server_id=server_id, action_id=action_id)
    already_filenames = h.fetchone_dict() or []

    if already_filenames:
        h = rhnSQL.prepare(_query_clear_action_config_filenames)
        h.execute(server_id=server_id, action_id=action_id)

    num_paths = len(paths)

    h = rhnSQL.prepare(_query_create_action_config_filename)
    h.execute_bulk({
        'action_id' : [action_id] * num_paths,
        'server_id' : [server_id] * num_paths,
        'path' : paths,
        })

    upload(server_id, action_id, data)
开发者ID:T-D-Oe,项目名称:spacewalk,代码行数:33,代码来源:configfiles.py

示例15: update_push_client_jid

def update_push_client_jid(server_id, jid):
    h1 = rhnSQL.prepare(_query_delete_duplicate_client_jids)
    h1.execute(server_id=server_id, jid=jid)
    h2 = rhnSQL.prepare(_query_update_push_client_jid)
    h2.execute(server_id=server_id, jid=jid)
    rhnSQL.commit()
    return jid
开发者ID:flavio,项目名称:spacewalk,代码行数:7,代码来源:server_lib.py


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