Skip to content

Commit

Permalink
Fix import error
Browse files Browse the repository at this point in the history
  • Loading branch information
saeeddhqan committed Aug 6, 2023
1 parent 1c493bd commit 90a9952
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
22 changes: 14 additions & 8 deletions maryam/core/initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

__version__ = 'v2.5.1'
__version__ = 'v2.5.2'

import argparse
import imp
import importlib
import os
import shutil
import sys
Expand Down Expand Up @@ -101,6 +101,12 @@ def _init_home(self):
if not os.path.exists(self._home):
os.makedirs(self._home)

def _load_a_module(self, mod_name, mod_path):
spec = importlib.util.spec_from_file_location(mod_name, mod_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module

def _init_util_classes(self, require='*'):
util_path = os.path.join(self.core_path, 'util')
for dirpath, _, files in os.walk(util_path, followlinks=True):
Expand All @@ -110,37 +116,37 @@ def _init_util_classes(self, require='*'):
mod_name = file.split('.')[0]
mod_path = os.path.join(dirpath, file)
try:
imp.load_source(mod_name, mod_path, open(mod_path)).main
module = self._load_a_module(mod_name, mod_path)
except Exception as e:
self.error(f"Util class '{mod_name}' has been disabled due to this error: {e}", 'initial', '_init_util_classes')
else:
exec(f"self.{mod_name} = sys.modules['{mod_name}'].main")
exec(f"self.{mod_name} = module.main")
exec(f"self.{mod_name}.framework = self")

def _load_modules(self, require='*'):
self.loaded_category = {}
self._loaded_modules = core._loaded_modules
self._init_util_classes(require)
for dirpath, dirnames, _ in os.walk(self.module_path, followlinks=True):
# Each Section
# Each section
for section in filter(lambda d: not d.startswith('__'), dirnames):
category = section
if require != category and require != '*': continue
self._cat_module_names[category] = []
section = os.path.join(dirpath, section)
for _, _, files in os.walk(section):
# Each File
# Each file
for file in filter(lambda f: f.endswith(self.module_ext) and not f.startswith('__'), files):
mod_path = os.path.join(section, file)
mod_load_name = f"__{file.split('.')[0]}"
mod_disp_name = file.split('.')[0]
try:
imp.load_source(mod_load_name, mod_path, open(mod_path))
module = self._load_a_module(mod_load_name, mod_path)
except Exception as e:
if not self._global_options['api_mode']:
self.error(f"Module name '{mod_disp_name}' has been disabled due to this error: {e}", 'initial', '_load_modules')
else:
self._loaded_modules[mod_disp_name] = sys.modules[mod_load_name]
self._loaded_modules[mod_disp_name] = module
self._cat_module_names[category].append(mod_disp_name)
self._module_names.append(mod_disp_name)

Expand Down
2 changes: 0 additions & 2 deletions requirements
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ threadpoolctl
tokenizers
toolz
top2vec
torch
torchvision
tqdm
transformers
typing-extensions
Expand Down
44 changes: 22 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,40 @@

setup(
name='maryam',
version='2.5.2',
version='2.5.2-1',
url='https://github.com/saeeddhqan/Maryam',
author='Saeed Dehqan',
author_email='[email protected]',
packages=find_packages(),
include_package_data=True,
package_data={"maryam": ['data/*']},
package_data={"maryam": ['data/*', 'modules/osint/*', 'modules/search/*', 'modules/iris/*', 'modules/footprint/*']},
license='GPL-V3',
description='OWASP Maryam is a modular/optional open-source framework based on OSINT and data gathering.',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
keywords=['OWASP', 'OSINT', 'search-engine', 'social-networks', 'Maryam'],
scripts=['bin/maryam'],
install_requires=[
'requests',
'cloudscraper',
'bs4',
'lxml',
'flask',
'vaderSentiment',
'plotly',
'matplotlib',
'pandas',
'wordcloud',
'numpy',
'dask',
'scikit-learn',
'scipy',
'umap',
'bertopic',
'sentence_transformers',
'gensim',
'top2vec'
],
'requests',
'cloudscraper',
'bs4',
'lxml',
'flask',
'vaderSentiment',
'plotly',
'matplotlib',
'pandas',
'wordcloud',
'numpy',
'dask',
'scikit-learn',
'scipy',
'umap',
'bertopic',
'sentence_transformers',
'gensim',
'top2vec'
],
classifiers=[
'Programming Language :: Python :: 3.10',
'Development Status :: 5 - Production/Stable',
Expand Down

0 comments on commit 90a9952

Please sign in to comment.