Exemplo n.º 1
0
 def create_user(self):
     """Create a new user account with a default password.  If an address is provided,
     an e-mail will be sent confirming the creation of the account."""
     self.setup()
     c.body=render('/derived/administration/create_user_form.html')
     c.user = None
     return render(ADMIN_HOME)
Exemplo n.º 2
0
 def delete_hostentry(self):
     """Delete an asset from the list"""
     self.topology = calypso.net.topology.Topology()
     name=request.params['name']
     print "PARAM" + str(request.params)
     if not(request.params.has_key("confirmed")):
         #confirm through dialog box if user really wishes to delete this item
         c.clientscript="""if(confirm('Really remove this asset?')) {
          $.ajax({
            type:'POST',
            data: {confirmed:'TRUE',
                  name : '%s'},
            url:'/administration/delete_hostentry',
            success:function(){window.location='/administration/configure_network';}
         });
         }"""%name
         c.message="Deleting asset \"%s\""%name
     else:
         #confirmed, so toss it:
         self.topology.remove_asset_by_name(name)
         c.body = render('/derived/administration/topology.html')
     self.topology = calypso.net.topology.Topology()
     self.setup()
     c.hosts = self.topology.hosts() 
     return render(ADMIN_HOME)
Exemplo n.º 3
0
 def configure_network(self):
     """Allows the user to define the topology of available hosts for connection to assets."""
     self.setup()
     h.withtitles=False
     self.topology = calypso.net.topology.Topology()
     c.hosts = self.topology.hosts()
     c.body = render('/derived/administration/topology.html')
     return render(ADMIN_HOME)
Exemplo n.º 4
0
 def backup_database(self):
     """Archive a snapshot of the current database contents.
     Upon confirmation from the user,  Calypso will provide a five minute warning to all
     active users of the system. An e-mail will also be sent to all users alerting them
     that the system will be unavailable."""
     self.setup()
     h.withtitles=False
     c.body=render('/derived/administration/backup_form.html')
     return render(ADMIN_HOME)
Exemplo n.º 5
0
 def edit_user(self,userid=None):
     """Edit a user's account information, including his or her user name, full name and e-mail information."""
     self.setup()
     if userid==None:
         print pylons.request.params
         userid=pylons.request.params['userid']
     c.user=calypso.db.session.query(calypso.users.User).filter_by(userid=userid).one()
     c.body=render('/derived/administration/edit_user_form.html')
     return render(ADMIN_HOME)
Exemplo n.º 6
0
 def render_html(self,for_editing=False, format=None):
     sqlsession.flush()
     c.name          = self.get_name()
     c.tiles         = self.tiles
     if format==None:
         c.format        = calypso.Session.session.get_display().format
     else:
         c.format=format
     if for_editing:
         return render('/tlm/develop/Visualization.html')
     else:
         return render ('/tlm/telemetrydisplay.html')
Exemplo n.º 7
0
 def add_asset(self):
     """Adds a user-requested asset to the list of assets.  If an entry with the name already exists,
     an error is displayed instead."""
     self.topology = calypso.net.topology.Topology()
     name=request.params['name']
     host=request.params['ip_address']
     port=int(request.params['port'])
     if(self.topology.hostdict().has_key(name)):
         c.clientscript="""alert('Name already exists.  Names must be unique.');"""
     else:
         self.topology.add_asset_by_name(name, host, port)
     self.setup()
     c.hosts = self.topology.hosts() 
     c.body = render('/derived/administration/topology.html')
     return render(ADMIN_HOME)
Exemplo n.º 8
0
    def archive_database(self):
        cron_entry={
            '12am' : '0 0',
            '2am': '0 2',
            '4am': '0 4',                     
            '6am': '0 6',
            '8am': '0 8',            
            '10am': '0 10',
            '12pm': '0 12',
            '2pm': '0 14',
            '4pm': '0 16',                     
            '6pm': '0 18',
            '8pm': '0 20',            
            '10pm': '0 22'            
                     }[request.params['tod'] + request.params['ampm'] ]
        
        cron_entry=cron_entry + { '0' : ' * * * ', #daily
                     '1' : ' 1 * * ', #weekly
                     '2' : ' 1 1 * ' #monthly
                     }[ request.params['schedule'] ]
        cron_entry=cron_entry + ' mysql'
        archive_name = request.params['archive_prefix'] + datetime.date.today().strftime('%Y_%m_%d') + '.sql'
        cron_entry=cron_entry + ' mysqldump Calypso -u jrusnak -p zg7jmttk > /home/jrusnak/'+archive_name

        tab=CronTab()        
        tab.remove_all('mysqldump')
        cron=tab.new()
        cron.parse(cron_entry)
        tab.write()
        self.setup()
        c.message="Successfully scheduled database backups "
        return render(ADMIN_HOME)
Exemplo n.º 9
0
 def view(self):
     # Return a rendered template
     #return render('/home.mako')
     # or, return a response
     if request.params.has_key('error'):
         c.errortext=request.params['error']
     return render('derived/home/home.html')
Exemplo n.º 10
0
 def render_html(self):
     c.name=self.name
     c.tiles=self.tiles
     c.scenario=session.usersession.scenario
     c.version =session.usersession.version        
     c.format  =session.usersession.display.format
     return render ('/tlm/telemetrydisplay.html')
Exemplo n.º 11
0
 def new_project(self):        
     project_name=self.form_result.get('project_name')
     contract_id=self.form_result.get('contract_id') 
     project_type=self.form_result.get('project_type')
     forms.UniqueProject.projects[project_name] = Project(project_name, contract_id, project_type=project_type)
     c.project_class='Project' 
     return render('/main/main.html')
Exemplo n.º 12
0
 def new_workbook(self):
     project_name=self.form_result.get('workbook_project_name')
     workbook_name=self.form_result.get('workbook_name')
     forms.UniqueWorkbook.workbooks[project_name + "." + workbook_name] = Workbook(project_name, workbook_name )
     c.project_type=forms.UniqueProject.projects[project_name].get_project_type()
     c.project_class='Project'
     return render('/main/workspace.html')
Exemplo n.º 13
0
 def rename_tab(self):
     self.load()
     newname = request.params["name"]
     if newname != c.window.get_name():
         self.tabstable[newname] = self.tabstable[c.window.get_name()]
         del self.tabstable[c.window.get_name()]
         c.window.set_name(newname)
         c.selected = newname
     return render("/tlm/develop/Visualization-main.html")
Exemplo n.º 14
0
 def move_tile(self):
     self.load()
     from_x_pos = int(request.params["from_x_pos"])
     from_y_pos = int(request.params["from_y_pos"])
     to_x_pos = int(request.params["to_x_pos"])
     to_y_pos = int(request.params["to_y_pos"])
     c.window.move_tile(from_x_pos=from_x_pos, from_y_pos=from_y_pos, to_x_pos=to_x_pos, to_y_pos=to_y_pos)
     c.selected_tile = c.window.select_tile(x_pos=to_x_pos, y_pos=to_y_pos)
     return render("/tlm/develop/Visualization-main.html")
Exemplo n.º 15
0
 def render_html(self):
     c.name=self.name
     c.scenario=session.usersession.scenario
     c.version=session.usersession.version
     session.usersession.display.format.connect()
     c.format=session.usersession.display.format
     c.tabs=self.tabs        
     c.selected=self.tabs[session.usersession.selectedtab].name
     c.tiles=self.tabs[session.usersession.selectedtab].tiles
     return render ('/tlm/telemetrydisplay.html')
Exemplo n.º 16
0
 def load(self,scenario, version):
     session=self._get_session(scenario,version)
     c.scenario=scenario
     c.version=version
     tag=scenario+"."+version
     session.set_display(self.__default_display())
     c.content= session.display.render_html()
     c.formatname = session.display.format.name
     c.display=session.display
     c.tasks=self.tasks
     ScenarioController.sessions[tag]=session
     return render("/derived/scenario.html")
Exemplo n.º 17
0
 def view(self,id):
     c.scenariolist=[]
     c.scenariolist=os.listdir(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))+"/scenarios")
     c.activescenarios=[]
     for scenario in c.scenariolist:
         if scenario!= "__init__.py" and scenario != "__init__.pyc":
             versions=os.listdir(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))+"/scenarios/"+scenario)
             for version in versions:
                 tag = scenario +"." + version
                 if (ScenarioController.sessions.has_key(tag)):
                     c.activescenarios.append(scenario+" version "+ version)
     return render('/derived/scenariolist.html')
Exemplo n.º 18
0
    def login(self):
      # Both fields filled?
       form_username = str(request.params.get('username'))
       form_password = str(request.params.get('password'))

      # Get user data from database
       user=calypso.users.User(form_username,
                               hashlib.md5(form_password).hexdigest())
       if not user.verify():           
           return render('/base/login.html')
       #BaseController.SQLSessions[form_username]=sqlsession
  
       # Mark user as logged in
       session['user'] = form_username
       session.save()

       # Send user back to the page he originally wanted to get to
       if session.get('path_before_login'):
           redirect_to(session['path_before_login'])
       else: # if previous target is unknown just send the user to a welcome page
           return render('index.html')
Exemplo n.º 19
0
 def update_user_data(self):
     """Commit updated user info to database in response to a user form submittal."""
     self.setup()
     if request.params.has_key('reset_password'):
         c.jscript="confirmed=confirm('Reset password and send e-mail for user "+request.params['userid'] +"?');"+"window.location='" + \
            h.url_for(controller='administration',
                   action='update_user_data')+"?confirmed='+confirmed;"
         self.user=calypso.db.session.query(calypso.users.User).filter_by(userid=request.params['olduserid']).one()
         self.user.password=hashlib.md5('default').hexdigest()
         #inform user via email
         msg = email.mime.text.MIMEText('Your password to Calypso has been reset to the default.  Please change it as soon as possible.')
         msg['Subject'] = 'Calypso passowrd reset'
         msg['From'] = '*****@*****.**'
         msg['To'] = self.user.email
         if self.user.email!='':
             s = smtplib.SMTP()
             s.connect('localhost')
             s.sendmail('*****@*****.**',
                        self.user.email,
                        msg.as_string())
             s.quit()
         c.message="Password successfully reset to default"
         return render(ADMIN_HOME)
     elif request.params.has_key('confirmed'):
         if request.params['confirmed']=='true':
             calypso.db.session.sqlsession.commit()
             c.message="User data has been updated"
         else:
             return self.edit_user(AdministrationController.user.userid)
     else:
         self.user=calypso.db.session.query(calypso.users.User).filter_by(userid=request.params['olduserid']).one()
         self.user.userid=request.params['userid']
         self.user.firstname=request.params['firstname']
         self.user.lastname = request.params['lastname']
         if request.params.has_key('email'):
             self.user.email=request.params['email']
         AdministrationController.user=self.user
         c.jscript="confirmed=confirm('Really update information for user "+request.params['userid'] +"?');"+"window.location='" + h.url_for(controller='administration',
                                                                                                                                              action='update_user_data')+"?confirmed='+confirmed;"
     return render(ADMIN_HOME)
Exemplo n.º 20
0
 def remove_tab(self):
     self.load()
     c.selected = request.params["tab"]
     self.tabstable[c.selected].delete()
     for index in range(len(self.tabs)):
         tab = self.tabs[index]
         if tab.get_name() == c.selected:
             del self.tabs[index]
             break
     del self.tabstable[c.selected]
     c.selected = self.tabs[0].get_name()
     c.window = self.tabs[0]
     return render("/tlm/develop/Visualization-main.html")
Exemplo n.º 21
0
    def render_tile_editor(self):
        try:
            self.load()
            c.x_pos = int(request.params["x_pos"])
            c.y_pos = int(request.params["y_pos"])
            c.tile = c.window.tiles[c.y_pos][c.x_pos].tile
            c.properties = c.window.tiles[c.y_pos][c.x_pos].properties

            return render("/tlm/develop/Visualization-tile_editor.html")
        except:
            import traceback

            traceback.print_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])
            pass
Exemplo n.º 22
0
 def add_user(self):
     self.setup()
     userid=request.params['userid']
     password=hashlib.md5('default').hexdigest()
     user = calypso.users.User(userid,password)
     user.firstname = request.params['firstname']
     user.lastname =  request.params['lastname']
     user.email = request.params['email']
     calypso.db.session.add(user)
     calypso.db.session.commit()
     c.message = 'User "' + user.firstname + ' ' + \
               user.lastname + '" has been created.'
     self.setup()
     return render(ADMIN_HOME)
Exemplo n.º 23
0
 def delete_user(self):
     self.setup()
     userid=request.params['userid']
     if userid=='admin':
         return render('derived/administration.html')
     if request.params.has_key('confirmed'):
         user=calypso.db.session.query(calypso.users.User).filter_by(userid=userid).one()
         if request.params['confirmed']=='true':
             calypso.db.session.delete(user)
             c.message="User with id " + userid + " has been deleted"
             self.setup()
             return render(ADMIN_HOME)
         else:
             return self.list_all_users()
     else:
         c.users = calypso.db.session.query(calypso.users.User).all()
         c.body = render('/derived/user_list.html')
         c.jscript="confirmed=confirm('Really delete user with id " + \
                    userid + "?');"+"window.location='" + \
            h.url_for(controller='administration',
                      action='delete_user') + \
                      "?confirmed='+confirmed+'&userid=" + \
                      userid + "';"
         return render(ADMIN_HOME)
Exemplo n.º 24
0
    def add_new_tab(self):
        try:
            basename = "Window"
            index = 0
            while self.tabstable.has_key(basename + str(index)):
                index += 1
            self.tabs.append(TelemetryWindow(self.user, basename + str(index), self))
            self.tabstable[basename + str(index)] = self.tabs[len(self.tabs) - 1]
            c.tabs = self.tabs
            c.selected = basename + str(index)
            c.window = self.tabstable[basename + str(index)]
            return render("/tlm/develop/Visualization-main.html")
        except:
            print "REQUEST PARAMS: " + str(request.params)
            import traceback

            traceback.print_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])
            raise
Exemplo n.º 25
0
 def append_tile(self):
     self.load()
     y_pos = int(request.params["y_pos"])
     x_pos = int(request.params["x_pos"])
     tiletype = request.params["type"]
     c.selected = request.params["tab"]
     c.window = self.tabstable[c.selected]
     index = 0
     basename = c.window.get_name() + "_Tile"
     while c.window.has_tile(basename + str(index)):
         index += 1
     tile = Tile(name=basename + str(index), user=self.user, parent=c.window, display=self, type=tiletype)
     properties = DisplayProperties(
         user=self.user, parent=tile, display=self, x_pos=x_pos, y_pos=y_pos, type=tiletype
     )
     # DisplayProperties.create_properties(name=tile.get_name(), user=self.user, parent=tile, display=self, x_pos=x_pos, y_pos=y_pos, type=tiletype)
     c.window.place_tile(tile=tile, properties=properties)
     return render("/tlm/develop/Visualization-main.html")  # tile.render_html(properties, True)
Exemplo n.º 26
0
 def display(self, scenario, version, display, tab):
     tag=scenario+"."+version
     ScenarioController.sessions[tag]=self._get_session(scenario,version)
     session=ScenarioController.sessions[tag]
     print "DISPLAY?" + str(isinstance(display,calypso.tlm.view.TelemetryDisplay))+display
     session.set_display(calypso.tlm.view.TelemetryDisplay.displays[display])
     
     c.scenario=scenario
     c.version=version
     c.format=session.display.format
     c.formatname=session.display.format.name
     try:
         c.selected=0
         while session.display.tabs[c.selected].name!=tab:
             c.selected=c.selected+1
     except:
         c.selected=0
     session.selectedtab=c.selected
     c.tabs=session.display.tabs
     c.tlmwindow=session.display.render_html()
     c.tasks=self.tasks
     c.display=session.display
     return render('/derived/scenario.html')
Exemplo n.º 27
0
 def render_html(self, properties, for_editing=False):
     sqlsession.flush()        
     sqlsession.commit()
     c.formatview= self.get_name().replace(' ','_')
     c.properties=properties
     c.monitors=self.monitors()
     c.flatattrs={}
     c.x_pos=properties.x_pos()
     c.y_pos=properties.y_pos()
     for mon in c.monitors:
         for attr in mon.attrs():
             if not(c.flatattrs.has_key(attr[0])):
                 c.flatattrs[attr[0]]=attr
     c.content_type = 'html'
     c.name         = self.display.format.name
     c.tile = self
     c.display_ops=for_editing
     try:
         return render('/tlm/develop/Visualization-tile_view.html');
     except:
         import traceback
         traceback.print_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])
         return "<b><i>ERROR rendering tile</i></b>"
Exemplo n.º 28
0
 def set_configuration(self):
     """Commit the user defined configuration"""
     config_path = __file__
     base_dir=os.path.dirname(config_path)
     config_file=os.path.join(base_dir,'../config/configuration.py')
     calypso.config.configuration.database_host=request.params['database_host']
     calypso.config.configuration.database_port=request.params['database_port']
     calypso.config.configuration.database_name=request.params['database_name']
     calypso.config.configuration.smtp_host=request.params['smtp_host']
     db_host=request.params['database_host']
     db_port=request.params['database_port']
     db_name=request.params['database_name']
     smtp_host=request.params['smtp_host']
     smtp_username=request.params['smtp_username']
     file = open(config_file,"w")
     file.write('database_host="'+ db_host+'"\n')
     file.write('database_port='+ db_port+'\n')
     file.write('database_name="'+ db_name+'"\n')
     file.write('smtp_host="' + smtp_host + '"\n')
     file.write('smtp_username="******"\n')
     file.close()
     self.setup()
     c.message="Successfully configured"
     return render(ADMIN_HOME)
Exemplo n.º 29
0
 def rename(self):
     newname=request.params['newname']
     self.tile.tile.set_name(newname)
     return render('/tlm/develop/Visualization-main.html')
Exemplo n.º 30
0
 def select_tab(self):
     c.selected = request.params["tab"]
     c.window = self.tabstable[c.selected]
     return render("/tlm/develop/Visualization-main.html")