Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
all_instances = [(ins.instance_type, get_friendly_platform(ins.platform), ins.placement, 1)
for ins in instances if "running" in ins.state]
ins_dict = summarize_tuples(all_instances).iteritems()
print "\n== Summary of running instances and their reserved instances ==\n"
yearly_savings = float(0)
monthly_savings = float(0)
upfront_cost = float(0)
total_instances = 0
res_instances = 0
monthly_od_sum = 0
monthly_ri_sum = 0
table = texttable.Texttable(max_width=0)
table.set_deco(texttable.Texttable.HEADER)
table.set_cols_dtype(['t', 't', 't', 't', 't', 't', 't', 't', 't'])
table.set_cols_align(["l", "l", "c", "c", "c", "r", "r", "r", "r"])
table.add_row(
["instance type", "platform", "zone", "# running", "# reserved",
"monthly savings", "yearly savings", "current monthly", "only_RIs monthly"])
for i in sorted(ins_dict):
# dict i is: {(inst_type, platform, az): count}
# find # of reserved instances, and # on-demand:
if i[0] in res_dict:
res_count = int(res_dict[i[0]])
else:
res_count = 0
run_count = int(i[1])
def printScanPortResults(self,results):
'''
resultats is a list of list
print resultat of scan port
'''
cleanList = []
results.insert(0,["PORT","PROTOCOL","STATE",'ERROR'])
table = Texttable(max_width=getScreenSize()[0])
table.set_deco(Texttable.HEADER)
if self.args['verbose']<2 :
for l in results:
if areEquals(l[2],'close')==False: cleanList.append(l)
results = cleanList
table.add_rows(results)
self.args['print'].goodNews("Scan report for {0}:\n{1}".format(self.args['scan-ports'][0],table.draw()))
def _has_header(self):
"""Return a boolean, if header line is required or not
"""
return self._deco & Texttable.HEADER > 0
def __init__(self, title = None):
Texttable.__init__(self)
# set class attributes so that it'll be more like TRex standard output
self.set_chars(['-', '|', '+', '-'])
self.set_deco(Texttable.HEADER | Texttable.VLINES)
self.title = title
default_table_width = 90
max_table_width = 600
try:
table_width = int(self.request.GET.get('table_width', default_table_width))
except ValueError:
table_width = default_table_width
else:
if table_width > max_table_width:
table_width = max_table_width
username_modifier = lambda x: u"<{0}>".format(x)
identity_col_width = reduce(lambda x,y: getmax_identity(x,y, username_cmp=username_modifier), messages, 10)
table = texttable.Texttable()
table.set_deco(texttable.Texttable.HEADER)
table.set_cols_dtype(["t", "t", "t"])
table.set_cols_align(["l", "l", "l"])
table.set_cols_valign(["t", "t", "t"])
table.set_cols_width([clock_col_width, identity_col_width, table_width-identity_col_width-clock_col_width])
for item in messages:
clock = item['clock'].strftime("%H:%M:%S")
if int(item.get('clock_indice', 1)) > 1:
clock += unicode(item['clock_indice'])
identity = item['user_agent']
if item['author__username']:
identity = username_modifier(item['author__username'])
message = item['raw']
def pretty_print(self, show_all=False):
"""Outputs the translation stats to a table formatted view."""
if not self.untranslated and not self.untagged:
self.log('\nNo untranslated strings found.\n')
return
# Most frequent untranslated and untagged messages.
if self.untagged:
table = texttable.Texttable(max_width=120)
table.set_deco(texttable.Texttable.HEADER)
table.set_cols_dtype(['t', 'i', 't'])
table.set_cols_align(['l', 'r', 'l'])
rows = []
missing = self.missing
for locale in missing:
for message in missing[locale]:
rows.append([str(locale), missing[locale][message], message])
rows = sorted(rows, key=lambda x: -x[1])
if not show_all:
num_rows = len(rows)
rows = rows[:self.ROW_COUNT]
if num_rows > self.ROW_COUNT:
rows.append(['', num_rows - self.ROW_COUNT,
'+ Additional untranslated strings...'])
total_imp_arg4
])
table_content.append([''] * len(table_row))
table_content.append(table_row)
table_header = ['Pred.', '# Pred.', '# Imp.Arg.', '# Imp./pred.']
if verbose >= 1:
table_header.extend([
'# Imp.Arg.in.range', '# Oracle', 'Oracle Recall'])
if verbose >= 2:
table_header.extend([
'# Imp.Arg.0', '# Imp.Arg.1', '# Imp.Arg.2',
'# Imp.Arg.3', '# Imp.Arg.4'])
table = Texttable()
table.set_deco(Texttable.BORDER | Texttable.HEADER)
table.set_cols_align(['c'] * len(table_header))
table.set_cols_valign(['m'] * len(table_header))
table.set_cols_width([15] * len(table_header))
table.set_precision(2)
table.header(table_header)
for row in table_content:
table.add_row(row)
print table.draw()
def get_network_list_table(self):
"""Return a table of networks registered on the node."""
# Create table and set headings
table = Texttable()
table.set_deco(Texttable.HEADER | Texttable.VLINES)
table.header(('Network', 'Physical Interface'))
# Obtain network configurations and add to table
for network_object in self.get_all_network_objects():
table.add_row((network_object.get_name(), network_object.get_adapter()))
return table.draw()
def _has_header(self):
"""Return a boolean, if header line is required or not
"""
return self._deco & Texttable.HEADER > 0
cloudsync = get_local_encrypted()
connections = 0; connection_groups = 0; identities = 0
snippets = 0; port_forwards = 0; amazon_ec2 = 0; config_items = 0
try:
objects = cloudsync[u'objects']
connections = num_unique_id_in_dict(objects, u'com.sonelli.juicessh.models.Connection')
connection_groups = num_unique_id_in_dict(objects, u'com.sonelli.juicessh.models.ConnectionGroup')
identities = num_unique_id_in_dict(objects, u'com.sonelli.juicessh.models.Identity')
snippets = num_unique_id_in_dict(objects, u'com.sonelli.juicessh.models.Snippet')
port_forwards = num_unique_id_in_dict(objects, u'com.sonelli.juicessh.models.PortForward')
except KeyError:
pass
config_items = num_unique_id_in_dict(cloudsync, u'configs')
table = Texttable()
table.set_deco(Texttable.HEADER)
table.set_cols_dtype(['t','i'])
table.set_cols_align(['l', 'c'])
print
print 'Remote Backups'
print '############################'
print 'Items currently in Cloudsync'
print
table.add_rows([['Type', 'Amount'],
['Connections', connections],
['Connection Groups', connection_groups],
['Identities', identities],
['Snippets', snippets],
['Port Forwards', port_forwards],
['Amazon EC2 Link Profiles*', amazon_ec2],
['Config Items', config_items]])
print table.draw()