def check_pep8(self): '''Check the PEP8 from current project ''' proj_dir = get_current_project().path kd_dir = get_kd_dir() pep8_dir = os.path.join(kd_dir, 'tools', 'pep8checker', 'pep8kivy.py') python_path =\ self.designer.designer_settings.config_parser.getdefault( 'global', 'python_shell_path', '' ) if python_path == '': self.profiler.dispatch('on_error', 'Python Shell Path not ' 'specified.' '\n\nUpdate it on \'File\' -> \'Settings\'') return if sys.platform[0] == 'w': pep8_dir = u'"' + pep8_dir + u'"' cmd = '%s %s %s' % (python_path, pep8_dir, proj_dir) self.designer.ui_creator.tab_pannel.switch_to( self.designer.ui_creator.tab_pannel.tab_list[2]) self.designer.ui_creator.kivy_console.run_command(cmd)
def check_pep8(self): '''Check the PEP8 from current project ''' proj_dir = get_current_project().path kd_dir = get_kd_dir() pep8_dir = os.path.join(kd_dir, 'tools', 'pep8checker', 'pep8kivy.py') python_path =\ self.designer.designer_settings.config_parser.getdefault( 'global', 'python_shell_path', '' ) if python_path == '': self.profiler.dispatch( 'on_error', 'Python Shell Path not ' 'specified.' '\n\nUpdate it on \'File\' -> \'Settings\'') return if sys.platform[0] == 'w': pep8_dir = u'"' + pep8_dir + u'"' cmd = '%s %s %s' % (python_path, pep8_dir, proj_dir) self.designer.ui_creator.tab_pannel.switch_to( self.designer.ui_creator.tab_pannel.tab_list[2]) self.designer.ui_creator.kivy_console.run_command(cmd)
def load_settings(self): '''This function loads project settings ''' self.config_parser = ConfigParser(name='DesignerSettings') DESIGNER_CONFIG = os.path.join(get_config_dir(), constants.DESIGNER_CONFIG_FILE_NAME) DEFAULT_CONFIG = os.path.join(get_kd_dir(), constants.DESIGNER_CONFIG_FILE_NAME) if not os.path.exists(DESIGNER_CONFIG): shutil.copyfile(DEFAULT_CONFIG, DESIGNER_CONFIG) self.config_parser.read(DESIGNER_CONFIG) self.config_parser.upgrade(DEFAULT_CONFIG) # creates a panel before insert it to update code input theme list panel = self.create_json_panel('Kivy Designer Settings', self.config_parser, os.path.join(get_kd_data_dir(), 'settings', 'designer_settings.json')) uid = panel.uid if self.interface is not None: self.interface.add_panel(panel, 'Kivy Designer Settings', uid) # loads available themes for child in panel.children: if child.id == 'code_input_theme_options': child.items = styles.get_all_styles() # tries to find python and buildozer path if it's not defined path = self.config_parser.getdefault( 'global', 'python_shell_path', '') if path.strip() == '': self.config_parser.set('global', 'python_shell_path', sys.executable) self.config_parser.write() buildozer_path = self.config_parser.getdefault('buildozer', 'buildozer_path', '') if buildozer_path.strip() == '': buildozer_path = find_executable('buildozer') if buildozer_path: self.config_parser.set('buildozer', 'buildozer_path', buildozer_path) self.config_parser.write() self.add_json_panel('Buildozer', self.config_parser, os.path.join(get_kd_data_dir(), 'settings', 'buildozer_settings.json')) self.add_json_panel('Hanga', self.config_parser, os.path.join(get_kd_data_dir(), 'settings', 'hanga_settings.json')) self.add_json_panel('Keyboard Shortcuts', self.config_parser, os.path.join(get_kd_data_dir(), 'settings', 'shortcuts.json'))
def validate_remote(self): '''Validates Git remote auth. If system if posix, returns True. If on NT, reads tools/ssh-agent/ssh_status.txt, if equals 1, returns True else runs the tools/ssh-agent/ssh.bat and returns False ''' if os.name == 'nt': script = os.path.join(get_kd_dir(), 'tools', 'ssh-agent', 'ssh.bat') status_txt = os.path.join(get_kd_dir(), 'tools', 'ssh-agent', 'ssh_status.txt') status = open(status_txt, 'r').read() status = status.strip() if status == '1': return True else: subprocess.call(script, shell=True) return False else: return True
def load_settings(self): '''This function loads project settings ''' self.config_parser = ConfigParser(name='DesignerSettings') DESIGNER_CONFIG = os.path.join(get_config_dir(), constants.DESIGNER_CONFIG_FILE_NAME) DEFAULT_CONFIG = os.path.join(get_kd_dir(), constants.DESIGNER_CONFIG_FILE_NAME) if not os.path.exists(DESIGNER_CONFIG): shutil.copyfile(DEFAULT_CONFIG, DESIGNER_CONFIG) self.config_parser.read(DESIGNER_CONFIG) self.config_parser.upgrade(DEFAULT_CONFIG) # creates a panel before insert it to update code input theme list panel = self.create_json_panel( 'Kivy Designer Settings', self.config_parser, os.path.join(get_kd_data_dir(), 'settings', 'designer_settings.json')) uid = panel.uid if self.interface is not None: self.interface.add_panel(panel, 'Kivy Designer Settings', uid) # loads available themes for child in panel.children: if child.id == 'code_input_theme_options': child.items = styles.get_all_styles() # tries to find python and buildozer path if it's not defined path = self.config_parser.getdefault('global', 'python_shell_path', '') if path.strip() == '': self.config_parser.set('global', 'python_shell_path', sys.executable) self.config_parser.write() buildozer_path = self.config_parser.getdefault('buildozer', 'buildozer_path', '') if buildozer_path.strip() == '': buildozer_path = find_executable('buildozer') if buildozer_path: self.config_parser.set('buildozer', 'buildozer_path', buildozer_path) self.config_parser.write() self.add_json_panel( 'Buildozer', self.config_parser, os.path.join(get_kd_data_dir(), 'settings', 'buildozer_settings.json')) self.add_json_panel( 'Hanga', self.config_parser, os.path.join(get_kd_data_dir(), 'settings', 'hanga_settings.json')) self.add_json_panel( 'Keyboard Shortcuts', self.config_parser, os.path.join(get_kd_data_dir(), 'settings', 'shortcuts.json'))
def validate_remote(self): '''Validates Git remote auth. If system if posix, returns True. If on NT, reads tools/ssh-agent/ssh_status.txt, if equals 1, returns True else runs the tools/ssh-agent/ssh.bat and returns False ''' if os.name == 'nt': script = os.path.join(get_kd_dir(), 'tools', 'ssh-agent', 'ssh.bat') status_txt = os.path.join(get_kd_dir(), 'tools', 'ssh-agent', 'ssh_status.txt') status = open(status_txt, 'r', encoding='utf-8').read() status = status.strip() if status == '1': return True else: subprocess.call(script, shell=True) return False else: return True
def load_repo(self, path): '''Load a git/non-git repo from path :param path: project path ''' self.path = path try: self.repo = Repo(path) self.is_repo = True branch_name = self.repo.active_branch.name self.dispatch('on_branch', branch_name) if os.name == 'posix': script = os.path.join(get_kd_dir(), 'tools', 'ssh-agent', 'ssh.sh') self.repo.git.update_environment(GIT_SSH_COMMAND=script) except InvalidGitRepositoryError: self.is_repo = False self._update_menu()