How to used sdaps setuptex command in python program - linux

I used sdaps command setup_tex to create a sdaps project in linux command line:
kashif#crunchbang:~$ sdaps /tmp/project setup_tex example.tex
which created project directory successfully, Now i want to use this command in my python program by executing this instruction:
sdaps.setuptex.setup.setup(survey, cmdline)
but don't know what exactly argument I should give to successfully execute to create project directory.

Anyhow i manage to create project by using os package i.e
import os
os.system("sdaps /tmp/project setup_tex example.tex")
but still i need standard documentation of sdaps usage with example so that i could make my own changes.

Related

What exactly is main.py in python and how do I use it to create a one file executable using pyinstaller?

I am currently working on a demo project while learning python and decided to use Tkinter as a user interface for my system. After finishing on the GUI and setting up a MySQL database I tried to use pyinstaller and py2exe to create a standalone .exe but it creates only one executable for one python file and I have 6 python files.
After research I found that most people with multiple python scripts have one main.py file that runs all their scripts and they use this to create a standalone .exe. So since this seems to be the solution but my question is, what is this main.py file and how do I write it so that when I create a .exe it runs my program and still has all the scripts working?
all my python scripts
The first script that I want to execute when run my program is Login.py

Execute python executable and script inlucing full path

Im trying to create a python script with executes a series of python and sql scripts.
Some need to be executed using one python executable and some using another.
I've tried
from subprocess import call
call([r"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\pythonw.exe", r"C:\Path\to\python\file\blabla.py"])
And
call([r"cd C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3", "pythonw.exe", r"C:\Path\to\python\file\blabla.py"])
But the script isnt being executed.
I think the problem might be "How to execute an .exe file in windows terminal including full path to it"?
Please check my code. It is working well in my side.
from subprocess import call
call([r"C:\Python38\python.exe", r"E:\python\hello.py"])
As i think, the problem is that you use pythonw.exe.
if you use pythonw.exe, you can see any log in terminal.
Pythonw is useful for running script with GUI.

Possible way to create a command line tool in node.js

I am building a nodejs based small framework for my application. Say, the name of the framework is coffee-cup, situated in the folder of the same name. The folder has a structure inside. To simplify the work of developers, I want to add few command line methods. For example, consider following folder structure.
coffee-cup
|--config
|--cups
|--cup1
|--index.js
|--report
|--cup-config
|--cup2
|--index.js
|--report
|--cup-config
We see that inside cup1 and cup2, there is same structure. If a developer wants to add a new cup called cup3, they will need to create a folder called cup3 and add the underlying structure into that folder.
To automate this task, I am thinking of a way to build a command line utility like
$ coffee-cup new cup cup3
that can work on linux, windows or mac terminals.
Expected result of Entering this command in terminal: would create a new folder called cup3 in cups folder and will create the file index.js and folders reporting and cup-config inside the folder cup3.
I can create folder using fs.mkdirSync()and file using fs.writeFile().
I am however, unable to find a way to make the terminal identify the coffee-cup command. If terminal identifies this command, it should collect the following arguments and pass on to the nodejs file and I can continue from there. What I know is, that there exist npm packages like inquire which are useful in creating command line applications. But it does not help in building command line utilities like I mentioned above.
So I am looking for guidance on making terminal identify the coffee-cup command, collect the following arguments and pass on everything to a nodejs file. It is just like we install npm and then terminal starts identifying the npm keyword and subsequent commands like $ npm install. Any help by experts will be highly appreciated.

Getting Error: 'No module named flask' in VSCode even when I have installed flask

I want to debug an application using Python and Flask in VSCode. I have installed Flask and the app runs perfectly fine through cmd. But, when I try to debug it through VSCode, it gives the following error:
cd 'c:\Users\Aditi\CleanHandymanApp';
${env:FLASK_APP}='NewApp'; ${env:PYTHONIOENCODING}='UTF-8';
${env:PYTHONUNBUFFERED}='1'; & 'C:\Users\Aditi\envs\CleanHandymanApp\Scripts\python.exe'
'c:\Users\Aditi\.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd_launcher.py' '--client' '--host'
'localhost' '--port' '63143' '-m' 'flask' 'run' '--no-debugger' '--no-reload'
No module named flask
Can you please help me.
This error message can occur if you installed the python3 version of flask but Visual Studio Code tries to run your project with python2.
Make sure to select the correct version of python in the editor. This can be done by running the command Python: Select Interpreter from the Command Palette (Ctrl+Shift+P).
Activate your virtualenv and run
pip3 install -r requirements.txt
to reinstall all packages inside the venv.
For some reason VS Code thought I was missing all my packages the first time I debugged even though the app was running fine locally.
Sometimes you can get this error if you loaded Flask into a folder which has sub-files. For instance, if you loaded flask into the parent folder with the virtual shell instance but you're running your code in the child file (let's say parent is called crypto_files and inside that is a python source code file called blockchain.py ), then in order to get flask to run properly you'd have to run the file like this:
python crypto_files/blockchain.py
This allows your machine to see Flask running inside crypto_files but also run blockchain.py .
OR, it's possibly you could just reload Flask into the sub(child)file... blockchain.py and then you'd run it from within the subfile.
This complication is mainly due to modern "virtual instances" and shells which are basically like creating a virtual computer-machine inside your ACTUAL hard machine. Flask does this to avoid running everywhere, and since Flask is modular it allows each of your projects to run different modular configurations of Flask to suit each project precisely. The alternative would be awful: you'd have to load the fattest version of Flask with dozens of add-ons for each project, and so all your git and all your projects would have tons of extra code. Flask is built to be very small at the core to avoid this problem (too verbose!).
If you have installed flask in virtual environment, you should have activated it first.
source /path to env dir/bin/activate #in linux
workon 'name of env' #windows
Another option is add sys.path.append('d:/programas/anaconda3/lib/site-packages') in c:\Users\Aditi.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd_launcher.py
Being that "d:/programas/anaconda3/lib/site-packages" should be modified by your local python packages.
Use this command in the terminal instead of selecting run code:
python3 "insert your file name here without the quotes"
e.g.: python3 example.py
I had a variant of the issue mentioned by #confusius. I had installed both Python 3.9 and Python 3.10. I had added Flask to Python 3.10. I had been using one vscode workspace which had selected Python 3.10. I started another project in a different vscode workspace and it had selected Python 3.9 by default, which I didn't notice because I thought it would select the same Python I had already selected in the other workspace.

julia: system image file "sys.ji" not found

I am using the IDE Netbeans to code a project c++ under Linux(red hat 7). As I need to use some math functions, I try to embed the julia language into my c++ project.
Here is what I have done:
Download the Julia from here (I choose this: Generic Linux binaries)
Set project properties: build-->C++ Complier-->Include Directories, add the include of Julia, something like this: ../myjulia/include/julia
Add the libraries: open a terminal and type the command line: sudo ln -s ../myjulia/lib/julia/libjulia.so /usr/lib/libjulia.so
Now if I run my project, I will get this error: System image file "../myproject/dist/Debug/GNU-Linux-x86/../lib/julia/sys.ji" not found
I hve checked this file: ../myjulia/lib/julia, in this file, there are all of the lib files (libjulia.so etc) and a file named "sys.ji".
I ran into this issue after installing Julia v0.3.10 on a Windows machine and thought I'd post it in case it can help someone else.
When I ran julia.exe it gave me the error message listed above.
Problem:
I had created a system environment variable called JULIA_HOME and pointed it to the directory where Julia was installed. Then, I added %JULIA_HOME%\bin to my PATH.
Solution:
I pointed JULIA_HOME to the \bin directory under the Julia install directory. Then, I added %JULIA_HOME% to my PATH
A "hello world" example from here
Now we know that we need to setup the julia context with this code:
jl_init(NULL);
In fact this code may not setup a good context because the project can't find the system image file "sys.ji". So what we need to do is using another function instead of jl_init: jl_init_with_image. This function accept two parameters: the first is the path of the image file, the second is the name of the image file. So we should use it like this: jl_init_with_image("/thePathOfSys.ji", "sys.ji"); One more thing: the path of sys.ji must be the absolute path.

Resources