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


Python Texttable.add_row方法代码示例

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


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

示例1: find_commands

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import add_row [as 别名]
def find_commands(db, *filters):
    user_filter = '\s+'.join(filters)
    user_re = re.compile(user_filter)
    RE_CACHE[user_filter] = user_re

    query = '''
    SELECT hostname, timestamp, duration, user_string
    FROM commands
    WHERE timestamp > ? AND user_string REGEXP ?
    ORDER BY timestamp
    '''

    table = Texttable()
    table.set_deco(Texttable.HEADER)
    table.set_cols_align(('l', 'r', 'r', 'l'))
    table.header(('host', 'date', 'duration', 'command'))

    host_width = 6
    max_command_width = 9
    now = time.time()
    for row in db.execute(query, (TIMESTAMP, user_filter)):
        host_width = max(host_width, len(row[0]))
        max_command_width = max(max_command_width, len(row[3]))
        table.add_row((
            row[0],
            format_time(row[1], now),
            format_duration(row[2]) if row[2] > 0 else '',
            highlight(row[3], user_re)))

    table.set_cols_width((host_width, 30, 10, max_command_width + 2))

    print table.draw()
开发者ID:minyoung,项目名称:dotfiles,代码行数:34,代码来源:find-commands.py

示例2: get_hard_drive_list_table

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import add_row [as 别名]
    def get_hard_drive_list_table(self):
        """Return a table of hard drives"""
        # Manually set permissions asserted, as this function can
        # run high privilege calls, but doesn't not require
        # permission checking
        self._get_registered_object('auth').set_permission_asserted()

        # Create table and set headings
        table = Texttable()
        table.set_deco(Texttable.HEADER | Texttable.VLINES)
        table.header(('ID', 'Size', 'Type', 'Storage Backend', 'Virtual Machine'))
        table.set_cols_width((50, 15, 15, 50, 20))

        # Obtain hard ives and add to table
        for hard_drive_obj in self.get_all():
            vm_object = hard_drive_obj.get_virtual_machine()
            hdd_type = ''
            storage_backend_id = 'Storage backend does not exist'
            try:
                storage_backend_id = hard_drive_obj.storage_backend.id_
                hdd_type = hard_drive_obj.get_type()
                hdd_size = SizeConverter(hard_drive_obj.get_size()).to_string()
            except (VolumeDoesNotExistError,
                    HardDriveDoesNotExistException,
                    StorageBackendDoesNotExist), exc:
                hdd_size = str(exc)

            table.add_row((hard_drive_obj.id_, hdd_size,
                           hdd_type, storage_backend_id,
                           vm_object.get_name() if vm_object else 'Not attached'))
开发者ID:ITDevLtd,项目名称:MCVirt,代码行数:32,代码来源:factory.py

示例3: __repr__

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import add_row [as 别名]
 def __repr__(self):
   t = Texttable()
   
   for rowId in range(0,self.size[0]):
     rowDetails = []
     for cellId in range(0,self.size[1]):
       cell = self.cellAtLocation(cellId,rowId)
       
       color = {
         "free":   bcolors.WHITE,
         "mine":   bcolors.PURPLE,
         "theirs": bcolors.RED
       }[cell.getState()]
       
       rowDetails.append(
         get_color_string(color, cell)
       )
     
     t.add_row(rowDetails)
   
   return "\n".join([
     t.draw(),
     self.board,
     self.state
   ])
开发者ID:YoSmudge,项目名称:goatpress-smudgebot,代码行数:27,代码来源:player.py

示例4: do_list

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import add_row [as 别名]
 def do_list(self, args):
         try:                        
                 #call UForge API
                 printer.out("Getting scans for ["+self.login+"] ...")
                 myScannedInstances = self.api.Users(self.login).Scannedinstances.Get(None, Includescans="true")
                 if myScannedInstances is None or not hasattr(myScannedInstances, 'get_scannedInstance'):
                         printer.out("No scans available")
                         return
                 else:
                         table = Texttable(800)
                         table.set_cols_dtype(["t","t","t","t"])
                         table.header(["Id", "Name", "Status", "Distribution"])
                         myScannedInstances = generics_utils.oder_list_object_by(myScannedInstances.get_scannedInstance(), "name")
                         for myScannedInstance in myScannedInstances:
                                     table.add_row([myScannedInstance.dbId, myScannedInstance.name, "", myScannedInstance.distribution.name + " "+ myScannedInstance.distribution.version + " " + myScannedInstance.distribution.arch])
                                     scans = generics_utils.oder_list_object_by(myScannedInstance.get_scans().get_scan(), "name")
                                     for scan in scans:
                                                 if (scan.status.complete and not scan.status.error and not scan.status.cancelled):
                                                         status = "Done"
                                                 elif(not scan.status.complete and not scan.status.error and not scan.status.cancelled):
                                                         status = str(scan.status.percentage)+"%"
                                                 else:
                                                         status = "Error"
                                                 table.add_row([scan.dbId, "\t"+scan.name, status, "" ])
                                                 
                         print table.draw() + "\n"
                         printer.out("Found "+str(len(myScannedInstances))+" scans")
         except ArgumentParserError as e:
                 printer.out("ERROR: In Arguments: "+str(e), printer.ERROR)
                 self.help_list()
         except Exception as e:        
                 return generics_utils.handle_uforge_exception(e)
开发者ID:radbrawler,项目名称:hammr,代码行数:34,代码来源:scan.py

示例5: do_search

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import add_row [as 别名]
    def do_search(self, args):
        try:
            #add arguments
            doParser = self.arg_search()
            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("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(Query="name=="+doArgs.pkg)
            pkgs = pkgs.pkgs.pkg
            if pkgs is None or len(pkgs) == 0:
                printer.out("No package found")
            else:
                table = Texttable(800)
                table.set_cols_dtype(["t","t","t","t","t","t","t"])
                table.header(["Name", "Version", "Arch", "Release", "Build date", "Size", "FullName"])
                pkgs = generics_utils.order_list_object_by(pkgs, "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), pkg.fullName])
                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:
            return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:hammr,代码行数:34,代码来源:os.py

示例6: print_table

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import add_row [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 add_row [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 add_row [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 add_row [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 add_row [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 add_row [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 add_row [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 add_row [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: do_info_draw_publication

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import add_row [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

示例15: do_delete

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import add_row [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.add_row方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。