Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update utils.py fixed Error file not found error message. #36

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

a7t0fwa7
Copy link
Contributor

The error message FileNotFoundError: [Errno 2] No such file or directory: 'filename' is being thrown because the tool is trying to open a file named 'filename' instead of the file you specified.

This issue arises from the file_exists function in the utils.py file of the crosslinked package. The function is supposed to check if the file you specified exists, but due to a bug, it's trying to open a file named 'filename' instead of the file you specified.

Here's the problematic code:

def file_exists(filename, contents=False):
    if not os.path.isfile(filename):
        print(f"[!] Input file not found: {filename}")
        exit(1)
    return [line.strip() for line in open('filename')] if contents else filename

As you can see, the open function is trying to open 'filename' instead of the file you specified. The correct code should be:

def file_exists(filename, contents=False):
    if not os.path.isfile(filename):
        print(f"[!] Input file not found: {filename}")
        exit(1)
    return [line.strip() for line in open(filename)] if contents else filename

Fix: modifying the file_exists function in the utils.py file of the crosslinked package.

@m8sec m8sec merged commit 9bb8fe2 into m8sec:master Feb 12, 2024
@m8sec
Copy link
Owner

m8sec commented Feb 12, 2024

Good catch thank you 😄

@a7t0fwa7
Copy link
Contributor Author

a7t0fwa7 commented Apr 2, 2024

No problems mate! 🤗

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

Successfully merging this pull request may close these issues.

None yet

2 participants