Пример #1
0
 def add_empty_session(self):
     #Check for various flags
     if self.edit_flag == True:
         return
     #Check if an empty session is already present
     for session_node in self.session_nodes:
         if session_node.type == self.ItemType.EMPTY_SESSION:
             return
     #Check where the session will be added
     #Initialize the session
     empty_session = settings.Session("")
     empty_session_node = self.SessionItem("")
     empty_session_node.parent = self
     empty_session_node.name = ""
     empty_session_node.session = empty_session
     empty_session_node.type = self.ItemType.EMPTY_SESSION
     empty_session_node.setEditable(True)
     empty_session_node.setIcon(self.node_icon_session)
     parent_group = self._get_current_group()
     if parent_group != None:
         empty_session.group = parent_group.name
         parent_group.appendRow(empty_session_node)
         self.expand(parent_group.index())
     else:
         self.tree_model.appendRow(empty_session_node)
     self.scrollTo(empty_session_node.index())
     #Start editing the new empty session
     self.session_nodes.append(empty_session_node)
     self.edit(empty_session_node.index())
     #Add the session signal when editing is canceled
     delegate = self.itemDelegate(empty_session_node.index())
     delegate.closeEditor.connect(self._item_editing_closed)
     #Store last created node type
     self.last_created_item = self.ItemType.EMPTY_SESSION
Пример #2
0
    def __init__(self, file_path):
        super(LogFile, self).__init__()

        self.path = file_path
        try:
            self.file = open(file_path, "r", encoding="latin-1")
        except (OSError, IOError):
            raise
        self.file_type = self.get_file_type()
        self.session = settings.Session()
Пример #3
0
 def test_create_student(self):
     s = orm.Student(name="Jacek",
                     surname="Bzdak",
                     gender=0,
                     status="status:doktorant",
                     message="foo")
     sess = settings.Session()
     try:
         sess.add(s)
         sess.commit()
     finally:
         sess.close()
     self.assertIsNotNone(s.id)
Пример #4
0
def create_session():
    """
    Contextmanager that will create and teardown a session.
    """
    session = settings.Session()
    try:
        yield session
        session.expunge_all()
        session.commit()
    except Exception:
        session.rollback()
        raise
    finally:
        session.close()
Пример #5
0
    def test_create_student_empty_name(self):
        """


        """
        raised_exception = False
        sess = settings.Session()
        try:
            sess.add(
                orm.Student(name=None,
                            surname="Bzdak",
                            gender=0,
                            status="status:doktorant",
                            message="foo"))
            sess.commit()
        except IntegrityError:
            raised_exception = True
        finally:
            sess.close()

        self.assertTrue(raised_exception)
Пример #6
0
 def __init__(self):
     self.headers = setting.headers
     self.songsheet_url = setting.songsheet_url
     self.sql_session = st.Session()
Пример #7
0
 def __init__(self):
     self.headers = setting.headers
     self.lyric_url = setting.lyric_url
     self.session = settings.Session()
Пример #8
0
 def __init__(self):
     self.headers = setting.headers
     self.comment_url = setting.comment_url
     self.comment_api = setting.comment_api
     self.encSecKey = self.rsaEncrypt()
     self.session = settings.Session()