예제 #1
0
파일: main.py 프로젝트: loggly/loggly-urly
    def get(self, code, format):
        if (code is None):
            logging.info("someone thinking about crafting a URL")
            MainView.render(self, 200, None, format)
            return

        ip = self.request.remote_addr 
        href = self.request.get('href').strip().encode('utf-8')
        title = self.request.get('title').strip().encode('utf-8')
        if (code == 'new') and (href is not None):
            try:
                u = Urly.find_or_create_by_href(href)
                if u is not None:
                    logging.info("creating urly by href: %s", str(href))
                    MainView.render(self, 200, u, format, href, title)
                else:
                    logging.info("error creating urly by href: %s", str(href))
                    MainView.render(self, 400, None, format, href)
            except db.BadValueError:
                # href parameter is bad
                logging.info("error with parameter")
                MainView.render(self, 400, None, format, href)
        else:
            u = Urly.find_by_code(str(code))
            if u is not None:
                logging.info("http://logg.ly/%s redirecting to %s for %s" % (code, u.href, ip))
                MainView.render(self, 200, u, format)
            else:
                logging.info("redirecting to loggly.com/%s" % code)
                self.redirect('http://www.loggly.com/%s' % code)
예제 #2
0
파일: main.py 프로젝트: xj361685640/hopr
class App(QtWidgets.QApplication):
    def __init__(self, scriptpath, sys_argv):
        super(App, self).__init__(sys_argv)
        self.model = MainModel()
        self.main_view = MainView(self.model, scriptpath)
        self.main_view.show()  #Maximized()
        self.model.gridChanged.emit()
예제 #3
0
    def __init__(self, sys_argv, fileName):
        super(App, self).__init__(sys_argv)

        self.fileName = fileName
        self.model = Model()
        self.controller = Controller(self.model, self.fileName)
        self.view = MainView(self.model, self.controller)
        self.view.show()
예제 #4
0
def main ():
    from model import MainModel
    from controller import MainController
    from view import MainView

    m = MainModel()
    v = MainView()
    c = MainController(m, v)

    gtk.main()
예제 #5
0
 def get(self, code, format):
     if (code is None):
         MainView.render(self, 200, None, format)
         user = users.get_current_user()
         if user: self.response.out.write("<a href=\"" + users.create_logout_url('/') + "\">Logout</a>")
         return
     
     u = Urly.find_by_code(str(code))
     if u is not None:
         MainView.render(self, 200, u, format, preview=True)
     else:
         MainView.render(self, 404, None, format)
예제 #6
0
 def get(self, format):
     url = self.request.get('url').strip()
     if url is not None:
         try:
             valid = Urly.validate_url(url)
             if valid:
                 u = Urly.find_or_create_by_url(url)
                 if u is not None:
                     MainView.render(self, 200, u, format)
                 else:
                     logging.error("Error creating urly by url: %s", str(url))
                     MainView.render(self, 400, None, format, url)
             else:
                 logging.error("Error creating urly by url: %s", str(url))
                 MainView.render(self, 400, None, format, url)
         except db.BadValueError:
             # url parameter is bad
             MainView.render(self, 400, None, format, url)
     else:
         self.redirect('/')
예제 #7
0
class Application:
    def __init__(self):
        self.model = Model();
        self.controller = Controller();
        self.mainView = MainView();

    def start(self):
        self.controller.setModel(self.model);
        self.mainView.setController(self.controller);

        self.model.start();
        self.controller.start();
        self.mainView.start();

        # mainView.start() is blocking. When it ends, the application can stop

        self.mainView.stop();
        self.controller.stop();
        self.model.stop();
예제 #8
0
import sys

from PySide2.QtWidgets import QApplication

from controller import MainModel
from controller import MainController
from view import MainView

if __name__ == '__main__':
    # Create the Qt Application
    app = QApplication(sys.argv)

    # Instantiate MVC classes and set bindings.
    # Binding order matters so that view and model are consistent:
    # (1) V<->M; (2) C<->M; (3) V<->C
    model = MainModel()
    view = MainView()
    view.bind_to_model(model)
    controller = MainController(model)
    controller.add_callbacks()
    view.bind_to_controller(controller)

    # Show and run QT loop
    view.show()
    sys.exit(app.exec_())
 def create_mv_instance(self, index):
     """ Creates class instances and saves these in a dictionary """
     if self.model.mv_empty(index):
         name = 'Device {}'.format(index)
         self.model.add_mv(index, mv.MainView(name))
예제 #10
0
파일: main.py 프로젝트: sevki/ur.ly
    def get(self, code, format):
        if (code is None):
            MainView.render(self, 200, None, format)
            return

        href = self.request.get('href').strip().encode('utf-8')
        title = self.request.get('title').strip().encode('utf-8')
        if (code == 'new') and (href is not None):
            try:
                u = Urly.find_or_create_by_href(href)
                if u is not None:
                    MainView.render(self, 200, u, format, href, title)
                else:
                    logging.error("Error creating urly by href: %s", str(href))
                    MainView.render(self, 400, None, format, href)
            except db.BadValueError:
                # href parameter is bad
                MainView.render(self, 400, None, format, href)
        else:
            u = Urly.find_by_code(str(code))
            if u is not None:
                MainView.render(self, 200, u, format)
            else:
                MainView.render(self, 404, None, format)
예제 #11
0
 def get(self,code):
     if code is None:
         MainView.render(self,200,None)
         return
     
     href = self.request.get('href').strip().encode('utf-8')
     title= self.request.get('title').strip().encode('utf-8')
     
     if code == 'new' and href is not None:
         try:
             url = PugPe.find_or_create_by_href(href)
             if url is not None:
                 MainView.render(self,200,url,href,title)
             else:
                 logging.error("Error creating urly by href: %s", str(href))
                 MainView.render(self,400,None,href)
         except db.BadValueError:
             #href parameter is bad
             MainView.render(self,400,None,href)
     else:
         url = PugPe.find_by_code(str(code))
         if url is not None:
             MainView.render(self,200,url)
         else:
             MainView.render(self,400,None)
예제 #12
0
from controller import ChatController, LoginController
from view import LoginView, MainView, MainWindow


def start_main():
    login_view = login_controller.view
    if login_view.userNameEdit.text() and login_view.passwordEdit.text(
    ) and login_controller.ready:
        chat_controller.server = login_controller.server
        chat_controller.init_view()
        chat_controller.init_user()
        MainWindow.show()


if __name__ == '__main__':
    app = QApplication(sys.argv)

    model = Model()
    # Initialize Login Page
    dialog = QDialog()
    MainWindow = MainWindow()
    login_page = LoginView(dialog)
    login_controller = LoginController(login_page, model)
    dialog.show()
    login_page.buttonBox.accepted.connect(start_main)

    # Initialize MainWindow
    main_ui = MainView(MainWindow)
    chat_controller = ChatController(main_ui, model, None)
    MainWindow.setController(chat_controller)
    sys.exit(app.exec_())
예제 #13
0
파일: main.py 프로젝트: omriiluz/urly
    def get(self, code, format):
        
        server = "http://" + self.request.environ["HTTP_HOST"]+"/"
        
        logging.info("*** Server is %s" % server)
        
        if (code is None):
            logging.info("*** Code is None")
            MainView.render(self, 200, None, format)
            return

        logging.info("*** Code is %s" % code)    
        
        href = self.request.get('href').strip().encode('utf-8')
        title = self.request.get('title').strip().encode('utf-8')
        if (code == 'new') and (href is not None):
            logging.info("href is %s" % href)
            try:
                u = Urly.find_or_create_by_href(href)
                if u is not None:
                    logging.debug("Rendering with server %s" % server)
                    MainView.render(self, 200, u, format, href, title,server)
                else:
                    logging.error("Error creating urly by href: %s", str(href))
                    MainView.render(self, 400, None, format, href)
            except db.BadValueError:
                # href parameter is bad
                MainView.render(self, 400, None, format, href)
        else:
            u = Urly.find_by_code(str(code))
            if u is not None:
                MainView.render(self, 200, u, format,href,title,server)
            else:
                MainView.render(self, 404, None, format)
예제 #14
0
파일: main.py 프로젝트: thomseddon/urly
 def get(self, code, format):
     if (code is None):
         MainView.render(self, 200, None, format)
         return
     
     base = self.request.get('href')
     params = self.request.arguments()
     for p in params:
         if (p != 'href') and (p != 'title'):
             base += '&'+str(p).strip()+'='+self.request.get(p).strip()
     href = base.strip().encode('utf-8')
     title = self.request.get('title').strip().encode('utf-8')
     if (code == 'new') and (href is not None):
         try:
             u = Urly.find_or_create_by_href(href)
             if u is not None:
                 MainView.render(self, 200, u, format, href, title)
             else:
                 logging.error("Error creating urly by href: %s", str(href))
                 MainView.render(self, 400, None, format, href)
         except db.BadValueError:
             # href parameter is bad
             MainView.render(self, 400, None, format, href)
     else:
         u = Urly.find_by_code(str(code))
         if u is not None:
             MainView.render(self, 200, u, format)
         else:
             MainView.render(self, 404, None, format)
예제 #15
0
 def __init__(self):
     self.model = Model();
     self.controller = Controller();
     self.mainView = MainView();
예제 #16
0
파일: main.py 프로젝트: halilcanakcay/urly
    def get(self, code, format):
        if code is None:
            MainView.render(self, 200, None, format)
            return

        href = self.request.get("href").strip().encode("utf-8")
        title = self.request.get("title").strip().encode("utf-8")
        if (code == "new") and (href is not None):
            try:
                u = Urly.find_or_create_by_href(href)
                if u is not None:
                    MainView.render(self, 200, u, format, href, title)
                else:
                    logging.error("Error creating urly by href: %s", str(href))
                    MainView.render(self, 400, None, format, href)
            except db.BadValueError:
                # href parameter is bad
                MainView.render(self, 400, None, format, href)
        else:
            u = Urly.find_by_code(str(code))
            if u is not None:
                MainView.render(self, 200, u, format)
            else:
                MainView.render(self, 404, None, format)