def system_has_calculator_parameters_test(): import models system = models.System() if not hasattr(system, 'calculator_parameters'): raise TypeError('system has no attribute calculator_parameters')
def system_has_free_energy_test(): import models system = models.System() if not hasattr(system, 'free_energy'): raise TypeError('system has no attribute free_energy')
def system_has_dipole_test(): import models system = models.System() if not hasattr(system, 'dipole'): raise TypeError('system has no attribute dipole')
def system_has_forces_test(): import models system = models.System() if not hasattr(system, 'forces'): raise TypeError('system has no attribute forces')
def system_has_constraints_test(): import models system = models.System() if not hasattr(system, 'constraints'): raise TypeError('system has no attribute constraints')
def system_has_ctime_test(): import models system = models.System() if not hasattr(system, 'ctime'): raise TypeError('system has no attribute ctime')
def system_has_query_test(): import models system = models.System() if not hasattr(system, 'query'): raise TypeError('system has no attribute query')
def __init__(self, *args, **kwargs): # Initialize the window super().__init__(*args, **kwargs) # Set window settings self.title("Charges and Fields") self.resizable(0, 0) # Set window display settings # Radius of particle self.particle_rad = 10 # Config sizing self.config_width = 800 self.config_height = 600 # Config arrow display type self.direction_only = IntVar() self.field_displayed = IntVar() self.scale_displayed = IntVar() self.grid_displayed = IntVar() # Load default particles p1 = models.Particle(100, 300, 1e-9) p2 = models.Particle(700, 300, -1e-9) self.system = models.System([p1, p2], 200) # PhotoImage for canvas screen self.volt_image = PhotoImage(width=self.config_width, height=self.config_height) # Instantiate widgets self.canvas = Canvas(self, width=self.config_width, height=self.config_height, bg="black", bd=0, highlightthickness=0) self.info_frame = InfoFrame( self.system, (self.direction_only, self.field_displayed, self.scale_displayed, self.grid_displayed), (self.add_pos_particle, self.add_neg_particle, self.delete_mode, self.add_sensor, self.display_volt), self, bd=0, highlightthickness=0) # Display PhotoImage for screen self.canvas.create_image( (self.config_width / 2, self.config_height / 2), image=self.volt_image, state=NORMAL) # Default check settings self.direction_only.set(0) self.field_displayed.set(1) self.scale_displayed.set(0) self.grid_displayed.set(0) # Display system fields self.display_field(self.system) # Initial display of particles self.display_particles(self.system) # Selected particle self.selected_particle = None # Cursor modes self.click_mode = None self.length_mode_bool = False # Select length coords self.length_start = (0, 0) # Set widget bindings # Binded canvas mouse motion to information update self.canvas.bind("<Motion>", self.info_frame.update) # Binded particles to click and movement update self.particle_bind() # Unselect movement select particle self.canvas.bind("<ButtonRelease-1>", self.unselect_particle) # Binded canvas click to measuretape self.canvas.bind("<Button-1>", self.length_mode) # Pack widgets into window grid self.canvas.grid(row=0, column=0) self.info_frame.grid(row=0, column=1) # Update window self.update() # Run loop self.after(0, self.loop) # Run window mainloop self.mainloop()
def system_has_numbers_test(): import models system = models.System() if not hasattr(system, 'numbers'): raise TypeError('system has no attribute numbers')
def system_has_positions_test(): import models system = models.System() if not hasattr(system, 'positions'): raise TypeError('system has no attribute positions')
def system_has_momenta_test(): import models system = models.System() if not hasattr(system, 'momenta'): raise TypeError('system has no attribute momenta')
def system_has_key_value_pairs_test(): import models system = models.System() if not hasattr(system, 'key_value_pairs'): raise TypeError('system has no attribute key_value_pairs')
def csv_import(request): from forms import CSVImportForm def generic_getter(field): return field def uppercase_getter(field): return field.upper() def allocation_getter(field): try: return models.Allocation.objects.get(name=field) except models.Allocation.DoesNotExist: return None def system_status_getter(field): try: return models.SystemStatus.objects.get(status=field) except models.SystemStatus.DoesNotExist: return def server_model_getter(field): try: return models.ServerModel.objects.get(id=field) except models.ServerModel.DoesNotExist: return def rack_getter(field): try: return models.SystemRack.objects.get(name=field) except models.SystemRack.DoesNotExist: return None ALLOWED_COLUMNS = { 'hostname': generic_getter, 'asset_tag': generic_getter, 'serial': uppercase_getter, 'notes': generic_getter, 'oob_ip': generic_getter, 'system_status': system_status_getter, 'allocation': allocation_getter, 'system_rack': rack_getter, 'rack_order': generic_getter, 'server_model': server_model_getter, 'purchase_price': generic_getter, } new_systems = 0 if request.method == 'POST': form = CSVImportForm(request.POST, request.FILES) if form.is_valid(): csv_reader = csv.reader(form.cleaned_data['csv']) headers = csv_reader.next() for line in csv_reader: cur_data = dict(zip(headers, line)) system_data = dict( (a, getter(cur_data.get(a, None))) for a, getter in ALLOWED_COLUMNS.iteritems()) s = models.System(**system_data) try: s.full_clean() except ValidationError, e: print e else: s.save() new_systems += 1 form = None
def system_has_id_test(): import models system = models.System() if not hasattr(system, 'id'): raise TypeError('system has no attribute id')
def system_has_text_keys_test(): import models system = models.System() if not hasattr(system, 'text_keys'): raise TypeError('system has no attribute text_keys')
def system_has_initial_charges_test(): import models system = models.System() if not hasattr(system, 'initial_charges'): raise TypeError('system has no attribute initial_charges')
hector.player_id = parker.id beatty = models.Character(name='Elsinore Beatty', tactician=0, level_headed=2) beatty.player_id = parker.id eclipse = models.Character(name='The Eclipse', tactician=2, level_headed=0, quick=True, hesitant=False) eclipse.player_id = parker.id sukorb = models.Character(name='Sukorb Tsif') sukorb.player_id = adam.id db.session.add(hector) db.session.add(beatty) db.session.add(eclipse) db.session.add(sukorb) db.session.commit() # Create System swade = models.System("Savage Worlds Adventurer's Edition") fifthed = models.System("Dungeons & Dragons: 5th Edition") fourthed = models.System("Dungeons & Dragons: 4th Edition") numenera = models.System("Numenera") cypher = models.System("Cypher System") strange = models.System("The Strange") db.session.add(swade) db.session.add(fifthed) db.session.add(fourthed) db.session.add(numenera) db.session.add(cypher) db.session.add(strange) db.session.commit() # Create Table