Ejemplo n.º 1
0
def create_home_dir():
    '''
    创建home目录。

    @return: 成功True。
    '''
    homeDir = get_home_dir()
    if not os.path.exists(homeDir):
        try:
            os.makedirs(homeDir)
        except OSError:
            return False

    # profile目录
    profilesPath = homeDir + os.path.sep + 'profiles'
    defaultProfilesPath = get_local_dir() + os.path.sep + 'profiles' + os.path.sep
    if not os.path.exists(profilesPath):
        try:
            shutil.copytree(defaultProfilesPath, profilesPath)
        except OSError:
            return False

    return True
Ejemplo n.º 2
0
                    self._write_to_file(div_end_str)

                div_end_str = u"\t\t</div>\n" u"\t</div>\n"
                self._write_to_file(div_end_str)

                html_end_str = u"</div>\n</body>\n</html>\n"
                self._write_to_file(html_end_str)

            except Exception, e:
                logger.error("Why this happen, report will return none:%s" % e)
                self._file.close()
                return None
        else:
            self._file.close()

        datetimestrf = datetime.now().strftime("%Y-%m-%d")
        import shutil

        typestr = "恶意内容扫描报告"

        final_report_path = get_local_dir() + os.path.sep + "reports" + os.path.sep
        final_name = self.target + "_" + datetimestrf + "_" + typestr + ".html"
        fin_path = os.path.join(final_report_path, final_name)

        if not os.path.exists(final_report_path):
            os.mkdir(final_report_path)

        shutil.move(self._file_path, fin_path)

        return fin_path
Ejemplo n.º 3
0
                div_end_str = u'\t\t</div>\n' \
                              u'\t</div>\n'
                self._write_to_file(div_end_str)

                html_end_str = u'</div>\n</body>\n</html>\n'
                self._write_to_file(html_end_str)

            except Exception, e:
                logger.error('Why this happen, report will return none:%s' % e)
                self._file.close()
                return None
        else:
            self._file.close()

        datetimestrf = datetime.now().strftime('%Y-%m-%d')
        import shutil

        typestr = '恶意内容扫描报告'

        final_report_path = get_local_dir(
        ) + os.path.sep + 'reports' + os.path.sep
        final_name = self.target + '_' + datetimestrf + '_' + typestr + '.html'
        fin_path = os.path.join(final_report_path, final_name)

        if not os.path.exists(final_report_path):
            os.mkdir(final_report_path)

        shutil.move(self._file_path, fin_path)

        return fin_path
Ejemplo n.º 4
0
        return None

    def getProfileValue(self, sectionName, optionName, valueType='string'):
        '''
        获取配置文件指定section、option的值。

        @param sectionName: 配置区域名称。
        @param optionName: 配置选项名称。
        @param valueType: 返回值类型,取值‘int’、‘string’、'list’
        '''
        for section in self._config.sections():
            if section == sectionName:
                for option in self._config.options(section):
                    if option == optionName:
                        if valueType == 'string':
                            return self._config.get(section, option)
                        elif valueType == 'int':
                            return self._config.getint(section, option)
                        else:
                            aList = []
                            for value in self._config.get(section,
                                                          option).split(','):
                                aList.append(value)
                            return aList

        return None


pf = Profile(get_local_dir() + os.path.sep + 'conf.dark')
Ejemplo n.º 5
0
        return None


    def getProfileValue(self, sectionName, optionName, valueType='string'):
        '''
        获取配置文件指定section、option的值。

        @param sectionName: 配置区域名称。
        @param optionName: 配置选项名称。
        @param valueType: 返回值类型,取值‘int’、‘string’、'list’
        '''
        for section in self._config.sections():
            if section == sectionName:
                for option in self._config.options(section):
                    if option == optionName:
                        if valueType == 'string':
                            return self._config.get(section, option)
                        elif valueType == 'int':
                            return self._config.getint(section, option)
                        else:
                            aList = []
                            for value in self._config.get(section, option).split(','):
                                aList.append(value)
                            return aList

        return None


pf = Profile(get_local_dir() + os.path.sep + 'conf.dark')