Skip to content

Commit

Permalink
Merge pull request #34 from fit-project/hotfix/pec-issues
Browse files Browse the repository at this point in the history
Hotfix/pec issues
  • Loading branch information
zitelog authored May 15, 2023
2 parents c649278 + 46579c8 commit 6ce2386
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 16 deletions.
2 changes: 2 additions & 0 deletions common/constants/view/pec/search_pec.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
PLACEHOLDER_PASSWORD="password"
PLACEHOLDER_IMAP_SERVER="imap.server.com"
PLACEHOLDER_IMAP_PORT="993"
PLACEHOLDER_SMPT_SERVER="smtp.server.com"
PLACEHOLDER_SMPT_PORT="456"
PLACEHOLDER_TO="[email protected]"
PLACEHOLDER_FROM="[email protected]"
PLACEHOLDER_SUBJECT="Some subject"
Expand Down
2 changes: 1 addition & 1 deletion model/configurations/tabs/pec/pec.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def set_default_values(self):
self.imap_server = ""
self.imap_port = ""
self.retries = 5
self.enabled = True
self.enabled = False

self.db.session.add(self)
self.db.session.commit()
Expand Down
16 changes: 11 additions & 5 deletions view/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def retranslateUi(self):

def load_tabs(self):
package=view.configurations
class_names_modules = {}
for importer, modname, ispkg in pkgutil.walk_packages(path=package.__path__, prefix=package.__name__+'.', onerror=lambda x: None):




#import module if not loaded
if modname not in sys.modules and not ispkg:
import_module(modname)
Expand All @@ -64,9 +64,15 @@ def load_tabs(self):
getattr(sys.modules[modname], '__is_tab__') and x.lower() == modname.rsplit( ".", 1 )[ 1 ]]

if class_name:
tab = getattr(sys.modules[modname], class_name[0])
tab = tab()
self.tabs.addTab(tab, tab.windowTitle())

class_names_modules.setdefault(class_name[0], []).append(sys.modules[modname])

ordered_keys = sorted(class_names_modules.keys())
for key in ordered_keys:
for value in class_names_modules[key]:
tab = getattr(value, key)
tab = tab()
self.tabs.addTab(tab, tab.windowTitle())

def accept(self) -> None:
for index in range(self.tabs.count()):
Expand Down
8 changes: 7 additions & 1 deletion view/configurations/tabs/pec/pec.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from common.constants import error
from controller.configurations.tabs.pec.pec import Pec as PecController
from view.error import Error as ErrorView
from common.constants.view.pec import pec
from common.constants.view.pec import pec, search_pec

__is_tab__ = True

Expand Down Expand Up @@ -60,6 +60,7 @@ def initUI(self):
self.horizontal_Layout_credential.addWidget(self.label_pec_email)
self.pec_email = QtWidgets.QLineEdit(self.form_layout_widget_credential)
self.pec_email.setEnabled(True)
self.pec_email.setPlaceholderText(search_pec.PLACEHOLDER_USERNAME)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand All @@ -72,6 +73,7 @@ def initUI(self):
self.horizontal_Layout_credential.addWidget(self.label_password)
self.password = QtWidgets.QLineEdit(self.form_layout_widget_credential)
self.password.setObjectName("password")
self.password.setPlaceholderText(search_pec.PLACEHOLDER_PASSWORD)
self.password.setEchoMode(QtWidgets.QLineEdit.Password)
self.horizontal_Layout_credential.addWidget(self.password)

Expand Down Expand Up @@ -101,13 +103,15 @@ def initUI(self):

self.imap_server = QtWidgets.QLineEdit(self.form_layout_widget_IMAP)
self.imap_server.setEnabled(True)
self.imap_server.setPlaceholderText(search_pec.PLACEHOLDER_IMAP_SERVER)
self.imap_server.setObjectName("imap_server")
self.horizontal_layout_IMAP.addWidget(self.imap_server)

self.label_imap_port = QtWidgets.QLabel(self.form_layout_widget_IMAP)
self.label_imap_port.setObjectName("label_imap_port")
self.horizontal_layout_IMAP.addWidget(self.label_imap_port)
self.imap_port = QtWidgets.QLineEdit(self.form_layout_widget_IMAP)
self.imap_port.setPlaceholderText(search_pec.PLACEHOLDER_IMAP_PORT)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand Down Expand Up @@ -146,6 +150,7 @@ def initUI(self):
self.horizontal_layout_SMTP.addWidget(self.label_smtp_server)
self.smtp_server = QtWidgets.QLineEdit(self.form_layout_widget_SMTP)
self.smtp_server.setEnabled(True)
self.smtp_server.setPlaceholderText(search_pec.PLACEHOLDER_SMPT_SERVER)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand All @@ -158,6 +163,7 @@ def initUI(self):
self.label_smtp_port.setObjectName("label_smtp_port")
self.horizontal_layout_SMTP.addWidget(self.label_smtp_port)
self.smtp_port = QtWidgets.QLineEdit(self.form_layout_widget_SMTP)
self.smtp_port.setPlaceholderText(search_pec.PLACEHOLDER_SMPT_PORT)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand Down
2 changes: 2 additions & 0 deletions view/post_acquisition/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def __thread_timestamp_is_finished(self,folder, case_info, type):
options = PecController().options
if options['enabled']:
self.send_report_from_pec(folder, case_info, type)
else:
self.is_finished_pec = True
self.parent().upadate_progress_bar()
self.is_finished_timestamp = True
self.__async_task_are_finished()
Expand Down
26 changes: 17 additions & 9 deletions view/web/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from PIL import Image

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, QWebEngineDownloadItem
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, QWebEngineDownloadItem, QWebEngineProfile

from view.web.navigationtoolbar import NavigationToolBar as NavigationToolBarView
from view.web.screenshot_select_area import SelectArea as SelectAreaView
Expand Down Expand Up @@ -84,10 +84,10 @@ def __init__(self, *args, **kwargs):

def init(self, case_info, wizard, options=None):


self.__init__()
self.wizard = wizard
self.case_info = case_info

self.configuration_view = ConfigurationView(self)
self.configuration_view.hide()

Expand All @@ -103,6 +103,7 @@ def init(self, case_info, wizard, options=None):

self.setCentralWidget(self.tabs)


self.status = QtWidgets.QStatusBar()
self.progress_bar = QtWidgets.QProgressBar()
self.progress_bar.setMaximumWidth(400)
Expand All @@ -124,7 +125,7 @@ def init(self, case_info, wizard, options=None):
self.start_acquisition_is_started = False
self.stop_acquisition_is_started = False


self.__clear_cache()
self.navtb = NavigationToolBarView(self)
self.addToolBar(self.navtb)

Expand Down Expand Up @@ -159,7 +160,6 @@ def init(self, case_info, wizard, options=None):

# Get timestamp parameters
self.configuration_timestamp = self.configuration_view.get_tab_from_name("configuration_timestamp")

self.add_new_tab(QtCore.QUrl(self.configuration_general.configuration['home_page_url']), 'Homepage')

self.show()
Expand All @@ -177,6 +177,9 @@ def init(self, case_info, wizard, options=None):

def start_acquisition(self):

profile = QWebEngineProfile.defaultProfile()
profile.clearHttpCache()

self.acquisition_directory = self.case_view.form.controller.create_acquisition_directory(
'web',
self.configuration_general.configuration['cases_folder_path'],
Expand Down Expand Up @@ -281,11 +284,9 @@ def __stop_acquisition_is_finished(self):
self.progress_bar.setHidden(True)
self.status.showMessage('')

# delete cookies from the store and clean the cache
cookie_store = self.tabs.currentWidget().page().profile().cookieStore()
cookie_store.deleteAllCookies()
self.tabs.currentWidget().page().profile().clearAllVisitedLinks()
self.tabs.currentWidget().page().profile().clearHttpCache()
self.__clear_cache()
profile = QWebEngineProfile.defaultProfile()
profile.clearHttpCache()

self.acquisition_is_running = False
self.start_acquisition_is_finished = False
Expand Down Expand Up @@ -553,6 +554,13 @@ def load_progress(self, progress):
self.current_page_load_is_finished = True
self.navtb.enable_screenshot_buttons()

def __clear_cache(self):

profile = QWebEngineProfile.defaultProfile()
profile.clearAllVisitedLinks()
cookie_store = profile.cookieStore()
cookie_store.deleteAllCookies()


def __update_urlbar(self, q, browser=None):
self.current_page_load_is_finished = False
Expand Down

0 comments on commit 6ce2386

Please sign in to comment.