Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

改进windows下的兼容性 #1354

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

改进windows下的兼容性 #1354

wants to merge 2 commits into from

Conversation

Pryriat
Copy link

@Pryriat Pryriat commented Feb 12, 2019

win10 1809,python 3.7.2 x86

upgrade cloghandler to concurrent_log_handler

在运行cobra.py时报以下错误:

PS F:\git\cobra> python cobra.py --help
Traceback (most recent call last):
  File "cobra.py", line 18, in <module>
    from cobra import main
  File "F:\git\cobra\cobra\__init__.py", line 21, in <module>
    from .log import logger
  File "F:\git\cobra\cobra\log.py", line 19, in <module>
    import cloghandler
ModuleNotFoundError: No module named 'cloghandler'

PS F:\git\cobra> pip install cloghandler
Collecting cloghandler
  Could not find a version that satisfies the requirement cloghandler (from versions: )
No matching distribution found for cloghandler

参考pypi说明,concurrent_log_handlercloghandler的新实现。

concurrent-log-handler 0.9.12

This is a fork from Lowell Alleman's version with updates for Windows and
recent versions of Python. It should be a drop-in replacement for users
of the old version, except for changing the package name from
cloghandler to concurrent_log_handler.

cloghandler替换为concurrent_log_handler,问题解决。

文件目录问题

解决上一问题后,报出以下错误

PS F:\git\cobra> python cobra.py --help
Traceback (most recent call last):
  File "cobra.py", line 18, in <module>
    from cobra import main
  File "F:\git\cobra\cobra\__init__.py", line 22, in <module>
    from . import cli, api, config
  File "F:\git\cobra\cobra\cli.py", line 17, in <module>
    from .detection import Detection
  File "F:\git\cobra\cobra\detection.py", line 20, in <module>
    from .config import rules_path
  File "F:\git\cobra\cobra\config.py", line 27, in <module>
    os.mkdir(code_path)
FileNotFoundError: [WinError 3] 系统找不到指定的路径。: '/tmp/cobra'

在windows下/tmp/cobra路径非法,修改为:在初始化code_path前对系统环境进行判断,如果为windows,目录变更为cobra项目目录/tmp

关于fcntl的建议

在windows下没有fcntl的实现,建议将实现内置于源码中,或者将fcntl置于项目目录下。

hjc981024 added 2 commits February 12, 2019 17:23
在windows环境下,创建目录位置更改为cobra项目路径/tmp
@towy
Copy link

towy commented Mar 5, 2019

fcntl.txt
Change to suffix .py
put into a C:\Python version\Lib
It can be run in
改为后缀.py
放在C:\Python版本\Lib 就能运行了

@LoRexxar
Copy link

windows下的问题不止这些,还有grep之类的,比较麻烦吧...以前提过一个issue,如果感兴趣可以自己改改看

#539

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants