Esempio n. 1
0
class Extreme_Interval():
	def __init__(self,fichero):
		self.__counter=0
		self.__bottom=Bottom(0x00);
		self.__top=Top(0xFF);
		self.__bits=Buffer(fichero)
	def __Is_underflow(self):
		return self.__top[:2]=="10" and self.__bottom[:2]=="01"
#		if self.__top>9 and self.__bottom>9:
#			First_digit_top=self.__top/first_digit_base
#			First_digit_bottom=self.__bottom/first_digit_base
#			print self.__top
#			print self.__bottom
#			print "primer digito top: ",First_digit_top
#			print "primer digito bottom",First_digit_bottom
#			dif_in_one= (First_digit_top-First_digit_bottom)==1
#			if dif_in_one: print "ES VERDAD"
#			top_list=",".join(str(self.__top))
#			top_list=top_list.split(",")
#			Second_digit_top=int(top_list[1])
#			bottom_list=",".join(str(self.__bottom))
#			bottom_list=bottom_list.split(",")
#			Second_digit_bottom=int(bottom_list[1])
#			if len(top_list)==len(bottom_list):
#				return Second_digit_top==0 and Second_digit_bottom==9 and dif_in_one
#		return False
	def __Get_list(self,number):
		string=",".join(str(number))
		return string.split(",")
#	def __Shift_extremes(self):
#		top_list=self.__Get_list(self.__top)
#		bottom_list=self.__Get_list(self.__bottom)
#		del top_list[1]
#		del bottom_list[1]
#		top_list.append("9")
#		bottom_list.append("0")
#		self.__top=int("".join(top_list))
#		self.__bottom=int("".join(bottom_list))
	def __Process_Underflow(self):
		while self.__top.Is_Underflow(self.__bottom):
#			print "UNDERFLOW!!!!!!!"
			self.__counter+=1;
			self.__shift()
	def __shift(self):
		self.__top<<1
		self.__bottom<<1
#		if bit_bot==1:
#			self.__bottom-=0x80
#			self.__top-=0x80
#		self.__bottom*=2
#		self.__top*=2
#		self.__top+=1
	def __Store_Partial_result(self):
#		bit_bot=self.__bottom/base_one_MSB;
#		bit_top=self.__top/base_one_MSB;
		
		while self.__top[0]==self.__bottom[0]:
#			print "bit bot ",bit_bot
#			if bit_bot==0: print "SON CERO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
			self.__bits.append(chr(ord("0")+int(self.__top[0])))
			bit_complement=int(bin(~int(self.__top[0]))[-1])
			for i in range(self.__counter):
				self.__bits.append(chr(ord("0")+bit_complement))
			self.__counter=0
#			print "corro 1 lugar"
			self.__shift()
#			print "top: ",int(self.__top)
#			print "bottom: ",int(self.__bottom)

	def Get_length(self):		
		return int(self.__top)-int(self.__bottom)
	def Get_Top(self):
		return int(self.__top)
	def Get_Bottom(self):
		return int(self.__bottom)
	def Set_extremes(self,bottom,top):
		self.__bottom.Set_value(bottom)
		self.__top.Set_value(top)
	def update_bottom(self,value):
#		print "Antes... bottom: ",int(self.__bottom)
#		print value
		self.__bottom+=int(value)
#		print "Despues... bottom: ",int(self.__bottom)
	def update_top(self,my_distance):
#		print "Antes... top: ",int(self.__top)
#		print "Distancia: ",my_distance
#		print "bottom + distancia: =",int(self.__bottom)+int(my_distance)
		self.__top.Set_value(int(self.__bottom)+ int(my_distance))
#		print "Despues... top: ",int(self.__top)
	def normalizate(self):
#		print "top: ",int(self.__top)
#		print "bottom: ",int(self.__bottom)
		self.__Process_Underflow();
		self.__Store_Partial_result();
	def All_data_stored(self):
		return self.__bits.All_data_stored();
	def Bit_padding(self):
		self.__bits.Bit_padding()
Esempio n. 2
0
	def __init__(self,fichero):
		self.__counter=0
		self.__bottom=Bottom(0x00);
		self.__top=Top(0xFF);
		self.__bits=Buffer(fichero)
Esempio n. 3
0
def call_print_one():
    Top.print_one()
Esempio n. 4
0
    def __init__(self, parent):
        GGrule.__init__(self, 1)  # this is the first rule to be executed
        # create the pattern...
        self.LHS = ASG_LinkedListMM()  # create LHS

        self.LHSnode1 = Top(parent)  # List head
        self.LHSnode1.graphObject_ = graph_Top(
            10, 10, self.LHSnode1)  # graphical representation...
        self.LHSnode1.setGGLabel(1)  # Set Graph Grammar Label...

        self.LHSnode2 = LLink(parent)  # Link to 1st. element
        self.LHSnode2.graphObject_ = graph_LLink(
            30, 60, self.LHSnode2)  # graphical representation...
        self.LHSnode2.setGGLabel(2)  # Set Graph Grammar Label...

        self.LHSnode3 = Element(parent)  # Any value
        self.LHSnode3.graphObject_ = graph_Element(
            10, 150, self.LHSnode3)  # graphical representation...
        self.LHSnode3.Label.setNone()
        self.LHSnode3.setGGLabel(3)  # Set Graph Grammar Label...

        self.LHSnode1.out_connections_.append(self.LHSnode2)  # n1 -> n2
        self.LHSnode2.in_connections_.append(self.LHSnode1)

        self.LHSnode2.out_connections_.append(self.LHSnode3)  # n2 -> n3
        self.LHSnode3.in_connections_.append(self.LHSnode2)

        self.LHS.addNode(self.LHSnode1)
        self.LHS.addNode(self.LHSnode2)
        self.LHS.addNode(self.LHSnode3)

        # create RHS...

        self.RHS = ASG_LinkedListMM()  # Also a Linked List...

        self.RHSnode1 = Top(parent)  # List head
        self.RHSnode1.graphObject_ = graph_Top(
            10, 10, self.RHSnode1)  # graphical representation...
        self.RHSnode1.setGGLabel(1)  # Set Graph Grammar Label...

        self.RHSnode2 = LLink(parent)  # Link to inserted element
        self.RHSnode2.graphObject_ = graph_LLink(
            30, 60, self.RHSnode2)  # graphical representation...
        self.RHSnode2.setGGLabel(2)  # Set Graph Grammar Label...

        self.RHSnode3 = Element(parent)  # NEW ELEMENT
        self.RHSnode3.Label.setValue('NEW ELEMENT')
        self.RHSnode3.graphObject_ = graph_Element(
            10, 150, self.RHSnode3)  # graphical representation...
        self.RHSnode3.setGGLabel(4)  # Set Graph Grammar Label (NEW LABEL)

        self.RHSnode4 = LLink(parent)  # Link to inserted element
        self.RHSnode4.graphObject_ = graph_LLink(
            30, 220, self.RHSnode4)  # graphical representation...
        self.RHSnode4.setGGLabel(5)  # Set Graph Grammar Label...

        self.RHSnode5 = Element(parent)  # Any value
        self.RHSnode5.Label.setNone()
        self.RHSnode5.graphObject_ = graph_Element(
            10, 280, self.RHSnode5)  # graphical representation...
        self.RHSnode5.setGGLabel(3)  # Set Graph Grammar Label...

        self.RHSnode1.out_connections_.append(self.RHSnode2)  # n1 -> n2
        self.RHSnode2.in_connections_.append(self.RHSnode1)

        self.RHSnode2.out_connections_.append(self.RHSnode3)  # n2 -> n3
        self.RHSnode3.in_connections_.append(self.RHSnode2)

        self.RHSnode3.out_connections_.append(self.RHSnode4)  # n3 -> n4
        self.RHSnode4.in_connections_.append(self.RHSnode3)

        self.RHSnode4.out_connections_.append(self.RHSnode5)  # n4 -> n5
        self.RHSnode5.in_connections_.append(self.RHSnode4)

        self.RHS.addNode(self.RHSnode1)
        self.RHS.addNode(self.RHSnode2)
        self.RHS.addNode(self.RHSnode3)
        self.RHS.addNode(self.RHSnode4)
        self.RHS.addNode(self.RHSnode5)
Esempio n. 5
0
import keep_alive,scratch3api,os, time
import Messages,Stats, Top
keep_alive.keep_alive()
Login=scratch3api.Send('-Dragonflyy' ,os.environ['Password'])
os.system('clear')

while True:
  os.system('clear')
  print('Updating message count...')
  Messages.update()
  time.sleep(.5)
  print('Checking for user stats...')
  Stats.check()
  time.sleep(.5)
  print('Updating top scratchers...')
  Top.update()
  time.sleep(.5)

#yo
#wassup
Esempio n. 6
0
   def __init__(self, parent):
      GGrule.__init__(self,1)                   		# this is the first rule to be executed
      # create the pattern...
      self.LHS = ASG_LinkedListMM()             		# create LHS

      self.LHSnode1 = Top(parent)                  		# List head
      self.LHSnode1.graphObject_ = graph_Top(10,10,self.LHSnode1) # graphical representation...
      self.LHSnode1.setGGLabel(1)				# Set Graph Grammar Label...

      self.LHSnode2 = LLink(parent)                		# Link to 1st. element
      self.LHSnode2.graphObject_ = graph_LLink(30,60,self.LHSnode2) # graphical representation...
      self.LHSnode2.setGGLabel(2)				# Set Graph Grammar Label...

      self.LHSnode3 = Element(parent)              		# Any value
      self.LHSnode3.graphObject_ = graph_Element(10,150,self.LHSnode3) # graphical representation...
      self.LHSnode3.Label.setNone()
      self.LHSnode3.setGGLabel(3)				# Set Graph Grammar Label...

      self.LHSnode1.out_connections_.append(self.LHSnode2)    	# n1 -> n2
      self.LHSnode2.in_connections_.append(self.LHSnode1)

      self.LHSnode2.out_connections_.append(self.LHSnode3)    	# n2 -> n3
      self.LHSnode3.in_connections_.append(self.LHSnode2)

      self.LHS.addNode(self.LHSnode1)
      self.LHS.addNode(self.LHSnode2)
      self.LHS.addNode(self.LHSnode3)

      # create RHS...

      self.RHS = ASG_LinkedListMM()				# Also a Linked List...

      self.RHSnode1 = Top(parent)				# List head
      self.RHSnode1.graphObject_ = graph_Top(10,10, self.RHSnode1) # graphical representation...
      self.RHSnode1.setGGLabel(1)				# Set Graph Grammar Label...

      self.RHSnode2 = LLink(parent)				# Link to inserted element
      self.RHSnode2.graphObject_ = graph_LLink(30,60, self.RHSnode2) # graphical representation...
      self.RHSnode2.setGGLabel(2)				# Set Graph Grammar Label...

      self.RHSnode3 = Element(parent)				# NEW ELEMENT
      self.RHSnode3.Label.setValue('NEW ELEMENT')
      self.RHSnode3.graphObject_ = graph_Element(10,150, self.RHSnode3) # graphical representation...
      self.RHSnode3.setGGLabel(4)				# Set Graph Grammar Label (NEW LABEL)

      self.RHSnode4 = LLink(parent)				# Link to inserted element
      self.RHSnode4.graphObject_ = graph_LLink(30,220,self.RHSnode4) # graphical representation...
      self.RHSnode4.setGGLabel(5)				# Set Graph Grammar Label...

      self.RHSnode5 = Element(parent)              		# Any value
      self.RHSnode5.Label.setNone()
      self.RHSnode5.graphObject_ = graph_Element(10,280, self.RHSnode5) # graphical representation...
      self.RHSnode5.setGGLabel(3)				# Set Graph Grammar Label...

      self.RHSnode1.out_connections_.append(self.RHSnode2)    	# n1 -> n2
      self.RHSnode2.in_connections_.append(self.RHSnode1)

      self.RHSnode2.out_connections_.append(self.RHSnode3)    	# n2 -> n3
      self.RHSnode3.in_connections_.append(self.RHSnode2)

      self.RHSnode3.out_connections_.append(self.RHSnode4)    	# n3 -> n4
      self.RHSnode4.in_connections_.append(self.RHSnode3)

      self.RHSnode4.out_connections_.append(self.RHSnode5)    	# n4 -> n5
      self.RHSnode5.in_connections_.append(self.RHSnode4)

      self.RHS.addNode(self.RHSnode1)
      self.RHS.addNode(self.RHSnode2)
      self.RHS.addNode(self.RHSnode3)
      self.RHS.addNode(self.RHSnode4)
      self.RHS.addNode(self.RHSnode5)
Esempio n. 7
0
import django.views

from horizon import exceptions
from horizon import forms

from openstack_dashboard import api
from openstack_dashboard.api import ceilometer
import sys,socket
from openstack_dashboard.dashboards.admin.monitoroverview import tabs as monitoroverview_tabs
import Top
from openstack_dashboard.openstack.common.mongodb import f_getMongodbIp
import logging

LOG = logging.getLogger(__name__)

cost_top = Top.Top(host_ip=f_getMongodbIp())
g_instance_id_name = {}

def get_instance_id_name(request):
    global g_instance_id_name
    try:
        instances, _more = api.nova.server_list(
            request,
            all_tenants=True)
        if instances:
            for i in instances:
                g_instance_id_name[i.id] = i.name
    except Exception:
        exceptions.handle(request,
                          _('Unable to retrieve instance list.'))