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


Python Texttable.header方法代码示例

本文整理汇总了Python中texttable.Texttable.header方法的典型用法代码示例。如果您正苦于以下问题:Python Texttable.header方法的具体用法?Python Texttable.header怎么用?Python Texttable.header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在texttable.Texttable的用法示例。


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

示例1: do_info_draw_publication

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
    def do_info_draw_publication(self, info_image):
        printer.out("Information about publications:")
        pimages = self.api.Users(self.login).Pimages.Getall()
        table = Texttable(0)
        table.set_cols_align(["l", "l"])

        has_pimage = False
        for pimage in pimages.publishImages.publishImage:
            if pimage.imageUri == info_image.uri:
                has_pimage = True
                cloud_id = None
                publish_status = image_utils.get_message_from_status(pimage.status)
                if not publish_status:
                    publish_status = "Publishing"

                if publish_status == "Done":
                    cloud_id = pimage.cloudId
                    format_name = info_image.targetFormat.format.name
                    if format_name == "docker" or format_name == "openshift":
                        cloud_id = pimage.namespace + "/" + pimage.repositoryName + ":" + pimage.tagName

                table.add_row([publish_status, cloud_id])

        if has_pimage:
            table.header(["Status", "Cloud Id"])
            print table.draw() + "\n"
        else:
            printer.out("No publication")
开发者ID:usharesoft,项目名称:hammr,代码行数:30,代码来源:image.py

示例2: schedule

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
    def schedule(self, label="default", *argvs, **kwargs):
        simulate = kwargs.get("simulate")
        reserver = kwargs.get("reserve")
        fullInfo = kwargs.get("fullInfo")

        if kwargs.get("list"):
            tp = TaskPeriod.objects.all()
            table = Texttable()
            table.set_deco(Texttable.HEADER)
            table.header(["Id", "Title", "Label", "Schedule"])
            for it in tp:
                table.add_row([it.id, it.title, it.label, it.cron])
            print(table.draw())

        if kwargs.get("template_id"):
            template_ids = kwargs.get("template_id")
            logger.debug("Schedule template id %s" % template_ids)

            filter = {"id__in": template_ids}
            self.scheduleByJobTemplates(
                filter, label, fullInfo, simulate, reserver)

        if kwargs.get("schedule_label"):
            period_label = kwargs.get("schedule_label")
            filter = {"schedule__label__in": period_label, "is_enable": True}
            if not label:
                label = period_label
            self.scheduleByJobTemplates(
                filter, "".join(label), fullInfo, simulate, reserver)
开发者ID:BlackSmith,项目名称:GreenTea,代码行数:31,代码来源:beaker.py

示例3: do_promote

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
    def do_promote(self, args):
        try:
            doParser = self.arg_promote()
            doArgs = doParser.parse_args(shlex.split(args))
            orgSpecified = org_utils.org_get(api=self.api, name=doArgs.org)

            adminUser = self.api.Users(doArgs.account).Get()

            if adminUser == None:
                printer.out("User [" + doArgs.account + "] doesn't exist.", printer.ERROR)
            else:
                self.api.Orgs(orgSpecified.dbId).Members(adminUser.loginName).Change(Admin=True, body=adminUser)
                printer.out("User [" + doArgs.account + "] has been promoted in [" + orgSpecified.name + "] :",
                            printer.OK)

            if adminUser.active == True:
                active = "X"
            else:
                active = ""

            printer.out("Informations about [" + adminUser.loginName + "] :")
            table = Texttable(200)
            table.set_cols_align(["c", "l", "c", "c", "c", "c", "c", "c"])
            table.header(
                ["Login", "Email", "Lastname", "Firstname", "Created", "Active", "Promo Code", "Creation Code"])
            table.add_row([adminUser.loginName, adminUser.email, adminUser.surname, adminUser.firstName,
                           adminUser.created.strftime("%Y-%m-%d %H:%M:%S"), active, adminUser.promoCode,
                           adminUser.creationCode])
            print table.draw() + "\n"
            return 0
        except ArgumentParserError as e:
            printer.out("In Arguments: " + str(e), printer.ERROR)
            self.help_promote()
        except Exception as e:
            return marketplace_utils.handle_uforge_exception(e)
开发者ID:hugo6,项目名称:marketplace-cli,代码行数:37,代码来源:user_admin_cmds.py

示例4: list

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
    def list(self):
        """List the Drbd volumes and statuses"""
        # Create table and add headers
        table = Texttable()
        table.set_deco(Texttable.HEADER | Texttable.VLINES)
        table.header(('Volume Name', 'VM', 'Minor', 'Port', 'Role', 'Connection State',
                      'Disk State', 'Sync Status'))

        # Set column alignment and widths
        table.set_cols_width((30, 20, 5, 5, 20, 20, 20, 13))
        table.set_cols_align(('l', 'l', 'c', 'c', 'l', 'c', 'l', 'c'))

        # Iterate over Drbd objects, adding to the table
        for drbd_object in self.get_all_drbd_hard_drive_object(True):
            table.add_row((drbd_object.resource_name,
                           drbd_object.vm_object.get_name(),
                           drbd_object.drbd_minor,
                           drbd_object.drbd_port,
                           'Local: %s, Remote: %s' % (drbd_object._drbdGetRole()[0].name,
                                                      drbd_object._drbdGetRole()[1].name),
                           drbd_object._drbdGetConnectionState().name,
                           'Local: %s, Remote: %s' % (drbd_object._drbdGetDiskState()[0].name,
                                                      drbd_object._drbdGetDiskState()[1].name),
                           'In Sync' if drbd_object._isInSync() else 'Out of Sync'))
        return table.draw()
开发者ID:joesingo,项目名称:MCVirt,代码行数:27,代码来源:drbd.py

示例5: do_list

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
 def do_list(self, args):
     try:
         #call UForge API
         printer.out("Getting distributions for ["+self.login+"] ...")
         distributions = self.api.Users(self.login).Distros.Getall()
         distributions = distributions.distributions
         if distributions is None or not hasattr(distributions, "distribution"):
             printer.out("No distributions available")
         else:
             table = Texttable(800)
             table.set_cols_dtype(["t","t","t","t","t", "t"])
             table.header(["Id", "Name", "Version", "Architecture", "Release Date", "Profiles"])
             distributions = generics_utils.order_list_object_by(distributions.distribution, "name")
             for distribution in distributions:
                 profiles = self.api.Distributions(distribution.dbId).Profiles.Getall()
                 profiles = profiles.distribProfiles.distribProfile
                 if len(profiles) > 0:
                     profile_text=""
                     for profile in profiles:
                         profile_text+=profile.name+"\n"
                     table.add_row([distribution.dbId, distribution.name, distribution.version, distribution.arch, distribution.releaseDate.strftime("%Y-%m-%d %H:%M:%S") if distribution.releaseDate is not None else "", profile_text])
                 else:
                     table.add_row([distribution.dbId, distribution.name, distribution.version, distribution.arch, distribution.releaseDate.strftime("%Y-%m-%d %H:%M:%S") if distribution.releaseDate is not None else "", "-"])
             print table.draw() + "\n"
             printer.out("Found "+str(len(distributions))+" distributions")
         return 0
     except ArgumentParserError as e:
         printer.out("ERROR: In Arguments: "+str(e), printer.ERROR)
         self.help_list()
     except Exception as e:
         return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:hammr,代码行数:33,代码来源:os.py

示例6: print_table

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
def print_table(prefix, items):
    table = Texttable(max_width=160)
    table.set_deco(Texttable.HEADER)
    table.header(['%s_id' % prefix, '%s_updated' % prefix, '%s_fk' % prefix])
    for key, values in items.iteritems():
        table.add_row([key, values.get('updated'), values.get('opposite_id')])
    print table.draw() + "\n"
开发者ID:KarstenFritz,项目名称:copydog,代码行数:9,代码来源:storage_browser.py

示例7: do_delete

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
    def do_delete(self, args):
        try:
            #add arguments
            doParser = self.arg_delete()
            doArgs = doParser.parse_args(shlex.split(args))

            #if the help command is called, parse_args returns None object
            if not doArgs:
                return 2

            #call UForge API
            printer.out("Searching bundle with id ["+doArgs.id+"] ...")
            myBundle = self.api.Users(self.login).Mysoftware(doArgs.id).Get()
            if myBundle is None or type(myBundle) is not MySoftware:
                printer.out("Bundle not found", printer.WARNING)
            else:
                table = Texttable(800)
                table.set_cols_dtype(["t","t","t", "t","t", "t"])
                table.header(["Id", "Name", "Version", "Description", "Size", "Imported"])
                table.add_row([myBundle.dbId, myBundle.name, myBundle.version, myBundle.description, size(myBundle.size), "X" if myBundle.imported else ""])
                print table.draw() + "\n"
                if generics_utils.query_yes_no("Do you really want to delete bundle with id "+str(myBundle.dbId)):
                    self.api.Users(self.login).Mysoftware(myBundle.dbId).Delete()
                    printer.out("Bundle deleted", printer.OK)


        except ArgumentParserError as e:
            printer.out("ERROR: In Arguments: "+str(e), printer.ERROR)
            self.help_delete()
        except Exception as e:
            return handle_uforge_exception(e)
开发者ID:lqueiroga,项目名称:hammr,代码行数:33,代码来源:bundle.py

示例8: render_datasets_as_table

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
def render_datasets_as_table(datasets, display_heading=True):
    """
    Returns ASCII table view of datasets.

    :param datasets: The datasets to be rendered.
    :type datasets: :class:`mytardisclient.models.resultset.ResultSet`
    :param render_format: The format to display the data in ('table' or
        'json').
    :param display_heading: Setting `display_heading` to True ensures
        that the meta information returned by the query is summarized
        in a 'heading' before displaying the table.  This meta
        information can be used to determine whether the query results
        have been truncated due to pagination.
    """
    heading = "\n" \
        "Model: Dataset\n" \
        "Query: %s\n" \
        "Total Count: %s\n" \
        "Limit: %s\n" \
        "Offset: %s\n\n" \
        % (datasets.url, datasets.total_count,
           datasets.limit, datasets.offset) if display_heading else ""

    table = Texttable(max_width=0)
    table.set_cols_align(["r", 'l', 'l', 'l'])
    table.set_cols_valign(['m', 'm', 'm', 'm'])
    table.header(["Dataset ID", "Experiment(s)", "Description", "Instrument"])
    for dataset in datasets:
        table.add_row([dataset.id, "\n".join(dataset.experiments),
                       dataset.description, dataset.instrument])
    return heading + table.draw() + "\n"
开发者ID:wettenhj,项目名称:mytardisclient,代码行数:33,代码来源:views.py

示例9: list

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
    def list(self):
        """List the Drbd volumes and statuses"""
        # Set permissions as having been checked, as listing VMs
        # does not require permissions
        self._get_registered_object('auth').set_permission_asserted()

        # Create table and add headers
        table = Texttable()
        table.set_deco(Texttable.HEADER | Texttable.VLINES)
        table.header(('Name', 'Type', 'Location', 'Nodes', 'Shared', 'Free Space', 'ID'))

        # Set column alignment and widths
        table.set_cols_width((15, 5, 30, 70, 6, 15, 50))
        table.set_cols_align(('l', 'l', 'l', 'l', 'l', 'l', 'l'))

        for storage_backend in self.get_all():
            table.add_row((
                storage_backend.name,
                storage_backend.storage_type,
                storage_backend.get_location(),
                ', '.join(storage_backend.nodes),
                str(storage_backend.shared),
                SizeConverter(storage_backend.get_free_space()).to_string(),
                storage_backend.id_
            ))
        return table.draw()
开发者ID:ITDevLtd,项目名称:MCVirt,代码行数:28,代码来源:factory.py

示例10: render_schemas_as_table

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
def render_schemas_as_table(schemas, display_heading=True):
    """
    Returns ASCII table view of schemas.

    :param schemas: The schemas to be rendered.
    :type schemas: :class:`mytardisclient.models.resultset.ResultSet`
    :param render_format: The format to display the data in ('table' or
        'json').
    :param display_heading: Setting `display_heading` to True ensures
        that the meta information returned by the query is summarized
        in a 'heading' before displaying the table.  This meta
        information can be used to determine whether the query results
        have been truncated due to pagination.
    """
    heading = "\n" \
        "Model: Schema\n" \
        "Query: %s\n" \
        "Total Count: %s\n" \
        "Limit: %s\n" \
        "Offset: %s\n\n" \
        % (schemas.url, schemas.total_count,
           schemas.limit, schemas.offset) if display_heading else ""

    table = Texttable(max_width=0)
    table.set_cols_align(["r", 'l', 'l', 'l', 'l', 'l', 'l'])
    table.set_cols_valign(['m', 'm', 'm', 'm', 'm', 'm', 'm'])
    table.header(["ID", "Name", "Namespace", "Type", "Subtype", "Immutable",
                  "Hidden"])
    for schema in schemas:
        table.add_row([schema.id, schema.name, schema.namespace,
                       schema.type, schema.subtype or '',
                       str(bool(schema.immutable)), str(bool(schema.hidden))])
    return heading + table.draw() + "\n"
开发者ID:wettenhj,项目名称:mytardisclient,代码行数:35,代码来源:views.py

示例11: render_instruments_as_table

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
def render_instruments_as_table(instruments, display_heading=True):
    """
    Returns ASCII table view of instruments.

    :param instruments: The instruments to be rendered.
    :type instruments: :class:`mytardisclient.models.resultset.ResultSet`
    :param render_format: The format to display the data in ('table' or
        'json').
    :param display_heading: Setting `display_heading` to True ensures
        that the meta information returned by the query is summarized
        in a 'heading' before displaying the table.  This meta
        information can be used to determine whether the query results
        have been truncated due to pagination.
    """
    heading = "\n" \
        "Model: Instrument\n" \
        "Query: %s\n" \
        "Total Count: %s\n" \
        "Limit: %s\n" \
        "Offset: %s\n\n" \
        % (instruments.url, instruments.total_count,
           instruments.limit, instruments.offset) if display_heading else ""

    table = Texttable(max_width=0)
    table.set_cols_align(["r", 'l', 'l'])
    table.set_cols_valign(['m', 'm', 'm'])
    table.header(["ID", "Name", "Facility"])
    for instrument in instruments:
        table.add_row([instrument.id, instrument.name, instrument.facility])
    return heading + table.draw() + "\n"
开发者ID:wettenhj,项目名称:mytardisclient,代码行数:32,代码来源:views.py

示例12: do_list

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
        def do_list(self, args):
                try:
                        doParser = self.arg_list()
                        doArgs = doParser.parse_args(shlex.split(args))

                        printer.out("Getting roles and their entitlements for user [" + doArgs.account + "]:\n")
                        roles = self.api.Users(doArgs.account).Roles.Getall()

                        table = Texttable(200)
                        table.set_cols_align(["l", "l"])
                        table.header(["Name", "Description"])
                        table.set_cols_width([30,60])
                        for role in roles.roles.role:
                                table.add_row([role.name.upper(), role.description])
                                for entitlement in role.entitlements.entitlement:
                                        table.add_row(["===> " + entitlement.name, entitlement.description])

                        printer.out("Role entitlements are represented with \"===>\".", printer.INFO)
                        print table.draw() + "\n"
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_list()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:28,代码来源:user_role.py

示例13: do_search

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
 def do_search(self, args):
         try:
                 #add arguments
                 doParser = self.arg_search()
                 try:
                         doArgs = doParser.parse_args(args.split())
                 except SystemExit as e:
                         return
                 #call UForge API
                 printer.out("Search package '"+doArgs.pkg+"' ...")
                 distribution = self.api.Distributions(doArgs.id).Get()
                 printer.out("for OS '"+distribution.name+"', version "+distribution.version)
                 pkgs = self.api.Distributions(distribution.dbId).Pkgs.Getall(Search=doArgs.pkg, Version=distribution.version)
                 
                 if pkgs is None or not hasattr(pkgs, 'pkgs'):
                         printer.out("No package found")
                 else:
                     table = Texttable(800)
                     table.set_cols_dtype(["t","t","t","t","t","t"])
                     table.header(["Name", "Version", "Arch", "Release", "Build date", "Size"])
                     pkgs = generics_utils.oder_list_object_by(pkgs.get_pkgs().get_pkg(), "name")
                     for pkg in pkgs:
                             table.add_row([pkg.name, pkg.version, pkg.arch, pkg.release, pkg.pkgBuildDate.strftime("%Y-%m-%d %H:%M:%S"), size(pkg.size)])
                     print table.draw() + "\n"
                     printer.out("Found "+str(len(pkgs))+" packages")
         except ArgumentParserError as e:
                 printer.out("ERROR: In Arguments: "+str(e), printer.ERROR)
                 self.help_search()
         except Exception as e:        
                 generics_utils.print_uforge_exception(e)
开发者ID:darkyat,项目名称:hammr,代码行数:32,代码来源:os.py

示例14: dump

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
def dump(relation):
  width,height = term_size()
  table = Texttable(width)


  sample, iterator = tee(relation)


  table.add_rows(take(1000,sample))
  table._compute_cols_width()
  del sample
  
  table.reset()

  table.set_deco(Texttable.HEADER)
  table.header([f.name for f in relation.schema.fields])



  rows = take(height-3, iterator)

  try:
    while rows:
      table.add_rows(rows, header=False)
      print table.draw()
      rows = take(height-3, iterator)
      if rows:
        raw_input("-- enter for more ^c to quit --")
  except KeyboardInterrupt:
    print
开发者ID:imclab,项目名称:splicer_console,代码行数:32,代码来源:splicer_console.py

示例15: do_delete

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import header [as 别名]
    def do_delete(self, args):
        try:
            #add arguments
            doParser = self.arg_delete()
            try:
                doArgs = doParser.parse_args(args.split())
            except SystemExit as e:
                return
            #call UForge API
            printer.out("Searching template with id ["+doArgs.id+"] ...")
            myAppliance = self.api.Users(self.login).Appliances(doArgs.id).Get()
            if myAppliance is None or type(myAppliance) is not Appliance:
                printer.out("Template not found")
            else:
                table = Texttable(800)
                table.set_cols_dtype(["t","t","t","t","t","t","t","t","t","t"])
                table.header(["Id", "Name", "Version", "OS", "Created", "Last modified", "# Imgs", "Updates", "Imp", "Shared"])
                table.add_row([myAppliance.dbId, myAppliance.name, str(myAppliance.version), myAppliance.distributionName+" "+myAppliance.archName,
                               myAppliance.created.strftime("%Y-%m-%d %H:%M:%S"), myAppliance.lastModified.strftime("%Y-%m-%d %H:%M:%S"), len(myAppliance.imageUris.uri),myAppliance.nbUpdates, "X" if myAppliance.imported else "", "X" if myAppliance.shared else ""])
                print table.draw() + "\n"

                if doArgs.no_confirm:
                    self.api.Users(self.login).Appliances(myAppliance.dbId).Delete()
                    printer.out("Template deleted", printer.OK)
                elif generics_utils.query_yes_no("Do you really want to delete template with id "+str(myAppliance.dbId)):
                    self.api.Users(self.login).Appliances(myAppliance.dbId).Delete()
                    printer.out("Template deleted", printer.OK)
            return 0
        except ArgumentParserError as e:
            printer.out("ERROR: In Arguments: "+str(e), printer.ERROR)
            self.help_delete()
        except Exception as e:
            return handle_uforge_exception(e)
开发者ID:ShigeruIchihashi,项目名称:hammr,代码行数:35,代码来源:template.py


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