Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7740787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:52:08+00:00 2026-06-01T08:52:08+00:00

So I have a directory tree as follows: pluginlist.py plugins/ __init__.py plugin1.py plugin2.py …

  • 0

So I have a directory tree as follows:

pluginlist.py
plugins/
    __init__.py
    plugin1.py
    plugin2.py
    ...

And want to concatenate a similarly-named dictionary from each of plugin1, plugin2, etc.

The way I’m doing this is as follows (from pluginlist.py):

import os

pluginFolderName = "plugins"
pluginFlag = "##&plugin&##"

commands = {}

os.chdir(os.path.abspath(pluginFolderName))

for file in os.listdir(os.getcwd()):
    if os.path.isfile(file) and os.path.splitext(file)[1] == ".py":
        fileo = open(file, 'r')
        firstline = fileo.readline()
        if firstline == "##&plugin&##\n":
            plugin_mod = __import__("plugins.%s" % os.path.splitext(file)[0])
            import_command = "plugin_commands = plugin_mod.%s" %     os.path.splitext(file)[0]
            exec import_command
            commands = dict(commands.items() + plugin_commands.commands.items())
print commands

(The print commands there is for testing purposes)

Running that on Windows gives the proper commands dictionary, but running it on Linux (Ubuntu Server) gives an empty dictionary.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:52:09+00:00Added an answer on June 1, 2026 at 8:52 am

    Figured out my problem! The

    os.path.isfile(file)
    

    test wasn’t working because Linux wanted an absolute path to the plugin file. So replacing all instances of file with

    os.path.join(os.getcwd(), file)
    

    Seems to fix everything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been sent a directory tree of source code that i want to
Situation is you have to develop an application against an Active Directory Tree. Want
I have a directory tree under SVN control, and I want to add and
I have a directory tree with sub-directories, and I want to add it to
I have a directory tree that I need to process as follows: I have
I'm new to visual studio, coming from Delphi. I have a directory tree full
I have used copydir to copy a directory tree but it is deprecated. My
i have this function to return the full directory tree : function getDirectory( $path
I have a python script that is trying to create a directory tree dynamically
I have a page which has a tree directory of people who work at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.