Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] List all files in the file pool in an inline script

edited October 2014 in OpenSesame

Hi, I'm new to OpenSesame and want to use it for an experiment.

I'd like to make my OpenSesame project somewhat generic and driven by the files that are in the file pool. For this I need to get a list of all files in the pool, but could not find a way to do this so far. The 'experiment' object in python only has methods to get a known file. I saw a forum post that says all files in the pool are extracted to a temporary directory but I do not know where it is.

How can I get a list of all the files in the pool?

Comments

  • edited 3:05AM

    Hi Mitko,

    Welcome to the forum!

    One way to do this is following. If you open the file pool, you see this little brownish cardbox/folder icon. Click on it and the directory of the file pool on your system will be opened. From there you can obtain its path.

    Next, you can import the python os library in an inline scriptand use its listdir(<path>)-method to get a list with all files in the directory.

    Does this help?

    Eduard

    Buy Me A Coffee

  • edited 3:05AM

    Hi Eduard,

    Thanks for your suggestion. That would work, but only on my computer. If I give the project to someone else, they will not be able to just run it.

    OpenSesame must know internally where the pool directory is. Isn't there a way to just get the path directly from the tool?

    Alternatively, if I understood this correctly, it is possible to use the project's directory instead of the internal pool. Is there a way to find what the project directory is within python?

    Mitko

  • edited 3:05AM

    Actually, I just realized the answer to my second question. I saw that the experiment has an experiment_path field that contains the experiment directory so now I can get all files there by simply doing:

    import os
    print os.listdir(exp.experiment_path)
    

    I will use this for now, but I am still interested whether I can get the file pool directory somehow from OpenSesame. I would prefer to package all my experiment data together with the project.

  • edited October 2014

    True, this wouldn't work if you want to use the same script and different machines.

    Well, in this case, you can try to work around the file pool at all.

    For example, place all your files in a folder, use the os module to get the all the file names, then loop over and concatenate them with the path to that folder. In doing so, you get the absolute path for each file and can use them as if they were in the file pool.

    If you place all your files in the directory, where your experiment is located, you can also access them directly. As Sebastiaan pointed out in another thread:

    The logic of filename resolution is as follows:

    1. Check if the file is in the file pool (subfolders not supported).
    2. If not, check if the file is in the experiment folder.
    3. If not, check if the file is in the "fallback-pool folder" (mostly for versioning, see here).
    4. If not, assume that the file is either absolute or relative to the current working directory.

    Eduard

    Buy Me A Coffee

  • edited 3:05AM

    Thanks for the help. As you suggest, I will go around the file pool entirely. I will place the files in the project directory and use the experiment_path to discover what files there are.

    Mitko

  • edited October 2014

    Alright then.

    By the way, I just found out how to get the path of the file pool.

    It is also part of the experiment and you can access it by typing self.experiment.pool_folder. (big surprise...)

    I guess that's all you need?

    Eduard

    Buy Me A Coffee

  • edited 3:05AM

    Oh, I saw pool_folder in the documentation but I thought it was used only for input. I should have tried it, I feel stupid now :)

    That's precisely what I needed, thanks a lot for this and for answering so quickly!

    Mitko

    P.S. Since I'm new, I don't know what's the proper way to mark this issue as resolved. Let me know if I need to do something.

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games