Modules and files

So far we've seen examples of using lager python with an individual python script (e.g. lager python You can also pass a directory to lager python instead of a file (e.g. lager python my_script_dir). Doing so will zip up all the files in the directory and send them to your gateway, and use as your entry point. Furthermore, any dependencies listed in your (optional) requirements.txt will be installed. Let's say you had a directory structure that looks like this:

├── files/
│   ├── my_first_file.txt
├── requirements.txt

We'll use our requirements.txt file to install texttable, a library for creating simple ASCII-art tables. We'll also read from a file - this will become especially useful when we want use lager python to programmatically flash our DUT.

from texttable import Texttable

def make_table():
    table = Texttable()
    table.set_cols_dtype(['t',  # text
                          'f',  # float (decimal)
                          'e',  # float (exponent)
                          'i',  # integer
                          'a']) # automatic
    table.set_cols_align(["l", "r", "r", "r", "l"])
    table.add_rows([["text",    "float", "exp", "int", "auto"],
                    ["abcd",    "67",    654,   89,    128.001],
                    ["efghijk", 67.5434, .654,  89.6,  12800000000000000000000.00023],
                    ["lmn",     5e-78,   5e-78, 89.4,  .000000000000128],
                    ["opqrstu", .023,    5e+78, 92.,   12800000000000000000000]])
    return table

def main():
    with open('files/my_first_file.txt') as f:

    table = make_table()

if __name__ == '__main__':
Hello, world! This is a file.
➜  lager python my_script_dir
Hello, world! This is a file.
 text     float       exp      int     auto
abcd      67.000   6.540e+02    89   128.001
efghijk   67.543   6.540e-01    90   1.280e+22
lmn        0.000   5.000e-78    89   0.000
opqrstu    0.023   5.000e+78    92   1.280e+22