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


Python Texttable.draw方法代码示例

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


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

示例1: do_list_changesets

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import draw [as 别名]
 def do_list_changesets(self, arg, opts=None):
     """Show changesets needing review."""
     changesets = requests.get(
         "http://%s/api/v1/changeset/" % self.site, params={"review_status": "needs"}, auth=self.api_auth
     )
     objects = changesets.json().get("objects")
     table = Texttable()
     table.set_deco(Texttable.HEADER)
     table.set_cols_align(["c", "c", "c", "c", "c"])
     table.set_cols_width([5, 20, 15, 15, 10])
     rows = [["ID", "Type", "Classification", "Version Control URL", "Submitted By"]]
     for cs in objects:
         user = requests.get("http://%s%s" % (self.site, cs.get("submitted_by")), auth=self.api_auth)
         user_detail = user.json()
         rows.append(
             [
                 cs.get("id"),
                 cs.get("type"),
                 cs.get("classification"),
                 cs.get("version_control_url"),
                 user_detail.get("name"),
             ]
         )
     table.add_rows(rows)
     print "Changesets That Need To Be Reviewed:"
     print table.draw()
开发者ID:killkill,项目名称:schemanizer,代码行数:28,代码来源:signin.py

示例2: do_list

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

示例3: do_search

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

示例4: log_api_exception

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import draw [as 别名]
def log_api_exception(sender, exception, **extra):
    fallback_message = u'Exception raised inside `log_api_exception`!'
    try:
        messages = []

        # If debugging or testing, log verbose request, browser, and user information
        if (sender.debug or sender.testing) and sender.config.get('API_LOG_EXTRA_REQUEST_INFO_ON_REQUEST_EXCEPTION'):
            request_info, browser_info, user_info = gather_api_exception_log_data()

            if request_info:
                table = Texttable()
                table.set_cols_width([10, 62])  # Accommodates an overall table width of 79 characters
                table.add_rows([('Request', 'Information')] + request_info)
                messages.append(table.draw())

            if browser_info:
                table = Texttable()
                table.add_rows([('Browser', 'Information')] + browser_info)
                messages.append(table.draw())

            if user_info:
                table = Texttable()
                table.add_rows([('User', 'Information')] + user_info)
                messages.append(table.draw())
        else:
            messages.append(u'{0}'.format(exception))

        message = '\n\n'.join(messages) if messages else None
    except Exception:
        message = fallback_message
    sender.logger.exception(message, **extra)
开发者ID:Catalant,项目名称:ct-flask-api-breakout,代码行数:33,代码来源:log_utils.py

示例5: do_delete

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

示例6: do_delete

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

示例7: print_mapping

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

示例8: dump

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

示例9: getAuccuracy

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import draw [as 别名]
def getAuccuracy( train, testSet, k ):
	totalCount = len(testSet)
	correctCount = 0.0;

	# Init ConfusionMatrix
	confusionMatrix = { }
	for i in featuresList:
		for j in featuresList:
			confusionMatrix[ (i,j) ] = 0

	for i in range(len(testSet)):
		predition = getPrediction( getDistancesOfKSimilarSets( train, testSet[i], k ) )
		if predition == testSet[i][-1]:
			correctCount+=1;
		confusionMatrix[ testSet[i][-1], predition ] += 1

	print "Confusion Matrix"
	from texttable import Texttable
	table=[]
	row=[""]
	row.extend(featuresList)
	table.append(row)
	for i in featuresList:
		row=[i]
		for j in featuresList:
			row.append( confusionMatrix[ (i,j) ])
		table.append(row)
	T=Texttable();
	T.add_rows(table)
	print T.draw();

	return correctCount*1.0/totalCount;
开发者ID:prabhakar9885,项目名称:Statistical-Methods-in-AI,代码行数:34,代码来源:kthNearestNeighbour_randomSampling.py

示例10: do_info_draw_general

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import draw [as 别名]
    def do_info_draw_general(self, info_image):
        table = Texttable(0)
        table.set_cols_dtype(["a", "t"])
        table.set_cols_align(["l", "l"])

        table.add_row(["Name", info_image.name])
        table.add_row(["Format", info_image.targetFormat.name])
        table.add_row(["Id", info_image.dbId])
        table.add_row(["Version", info_image.version])
        table.add_row(["Revision", info_image.revision])
        table.add_row(["Uri", info_image.uri])

        self.do_info_draw_source(info_image.parentUri, table)

        table.add_row(["Created", info_image.created.strftime("%Y-%m-%d %H:%M:%S")])
        table.add_row(["Size", size(info_image.fileSize)])
        table.add_row(["Compressed", "Yes" if info_image.compress else "No"])

        if self.is_docker_based(info_image.targetFormat.format.name):
            registring_name = None
            if info_image.status.complete:
                registring_name = info_image.registeringName
            table.add_row(["RegisteringName",registring_name])
            table.add_row(["Entrypoint", info_image.entrypoint.replace("\\", "")])

        self.do_info_draw_generation(info_image, table)

        print table.draw() + "\n"
开发者ID:usharesoft,项目名称:hammr,代码行数:30,代码来源:image.py

示例11: do_info_draw_publication

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

示例12: find_commands

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

示例13: do_list

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

                        printer.out("Getting entitlements list of the UForge :")
                        entList = self.api.Entitlements.Getall()
                        if entList is None:
                                printer.out("No entitlements found.", printer.OK)
                        else:
                                entList=generics_utils.order_list_object_by(entList.entitlements.entitlement, "name")
                                printer.out("Entitlement list for the UForge :")
                                table = Texttable(200)
                                table.set_cols_align(["l", "l"])
                                table.header(["Name", "Description"])
                                table.set_cols_width([30,60])
                                for item in entList:
                                        table.add_row([item.name, item.description])
                                print table.draw() + "\n"
                        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,项目名称:uforge-cli,代码行数:28,代码来源:entitlement.py

示例14: do_list

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import draw [as 别名]
    def do_list(self, args):
        try:
            org_name = None
            if args:
                do_parser = self.arg_list()
                try:
                    do_args = do_parser.parse_args(shlex.split(args))
                except SystemExit as e:
                    return
                org_name = do_args.org

            # call UForge API
            printer.out("Getting all the roles for the organization...")
            org = org_utils.org_get(self.api, org_name)
            all_roles = self.api.Orgs(org.dbId).Roles().Getall(None)

            table = Texttable(200)
            table.set_cols_align(["c", "c"])
            table.header(["Name", "Description"])
            for role in all_roles.roles.role:
                table.add_row([role.name, role.description])
            print table.draw() + "\n"
            return 0
        except ArgumentParserError as e:
            printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
            self.help_list()
        except Exception as e:
            return marketplace_utils.handle_uforge_exception(e)
开发者ID:hugo6,项目名称:marketplace-cli,代码行数:30,代码来源:rolecmds.py

示例15: do_list

# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import draw [as 别名]
    def do_list(self, args):
        try:
            #call UForge API
            printer.out("Getting generation formats for ["+self.login+"] ...")
            targetFormatsUser = self.api.Users(self.login).Targetformats.Getall()
            if targetFormatsUser is None or len(targetFormatsUser.targetFormats.targetFormat) == 0:
                printer.out("No generation formats available")
                return 0
            else:
                targetFormatsUser = generics_utils.order_list_object_by(targetFormatsUser.targetFormats.targetFormat,"name")
                table = Texttable(200)
                table.set_cols_align(["l", "l", "l", "l", "l", "c"])
                table.header(["Name", "Format", "Category", "Type", "CredAccountType", "Access"])
                for item in targetFormatsUser:
                    if item.access:
                        access = "X"
                    else:
                        access = ""
                    if item.credAccountType is None:
                        credAccountType = ""
                    else:
                        credAccountType = item.credAccountType
                    table.add_row(
                        [item.name, item.format.name, item.category.name, item.type, credAccountType,
                         access])
                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:hidakanoko,项目名称:hammr,代码行数:35,代码来源:format.py


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