Can the Import command be invoked via the Design Automation API? - autodesk-forge

I'm trying to invoke the AutoCAD Import command via the Design Automation API. This works fine from accoreconsole.exe locally, and while the Design Automation API accepts the Import command without error, it proceeds to the next command without importing anything.
In the excerpt of a Design Automation API output log below I'm invoking the Import command both directly from the generated script file and via SendStringToExecute via my plug-in. In the latter case I've pulled the full local file path.
[10/19/2017 06:20:18] Command: Import
[10/19/2017 06:20:18] Enter import file name: "input.stp"
[10/19/2017 06:20:18] Command: ProcessChamberDrawingCloud
[10/19/2017 06:20:19] Command: (command "Import" "\"T:\\Aces\\Jobs\\f4ba423419294f7eacf0d9fac71e790f\\input.stp\"")
[10/19/2017 06:20:19] Import
[10/19/2017 06:20:19] Enter import file name: "T:\Aces\Jobs\f4ba423419294f7eacf0d9fac71e790f\input.stp"
[10/19/2017 06:20:19] Command: _.quit

The 'IMPORT' command in Forge Design Automation have some problem, it doesn't spawn "AcTranslator.exe" process. we are working on some other alternative, we will keep you posted.
IMPORT is a two step process in AutoCAD
First it will spawn a child process like this AcTranslator.exe -i
"input.stp" -o "output.dwg"
When translation is done, a notification is sent to user in the
AutoCAD UI [Right Most corner of AutoCAD Main Window] when you click
on the notificaton bar, translated entities from output.dwg are merged in to current
drawing.
Currently, we see problem at first step.
edited
We have fixed this problem:
I have answered in another stack over flow post Import-In-Forge

For STEP files, the IMPORT command depends upon the AcTranslators.exe and several atf*.dll files. Does your environment have those files, will be the 1st question? But I'm still checking if there is some other approach.

Related

Internal server error when importing Python file into app.py when developing Flask we application [duplicate]

How are you meant to debug errors in Flask? Print to the console? Flash messages to the page? Or is there a more powerful option available to figure out what's happening when something goes wrong?
Running the app in debug mode will show an interactive traceback and console in the browser when there is an error. As of Flask 2.2, to run in debug mode, pass the --app and --debug options to the flask command.
$ flask --app example --debug run
Prior to Flask 2.2, this was controlled by the FLASK_ENV=development environment variable instead. You can still use FLASK_APP and FLASK_DEBUG=1 instead of the options above.
For Linux, Mac, Linux Subsystem for Windows, Git Bash on Windows, etc.:
$ export FLASK_APP=example
$ export FLASK_DEBUG=1
$ flask run
For Windows CMD, use set instead of export:
set FLASK_DEBUG=1
For PowerShell, use $env:
$env:FLASK_DEBUG = "1"
If you're using the app.run() method instead of the flask run command, pass debug=True to enable debug mode.
Tracebacks are also printed to the terminal running the server, regardless of development mode.
If you're using PyCharm, VS Code, etc., you can take advantage of its debugger to step through the code with breakpoints. The run configuration can point to a script calling app.run(debug=True, use_reloader=False), or point it at the venv/bin/flask script and use it as you would from the command line. You can leave the reloader disabled, but a reload will kill the debugging context and you will have to catch a breakpoint again.
You can also use pdb, pudb, or another terminal debugger by calling set_trace in the view where you want to start debugging.
Be sure not to use too-broad except blocks. Surrounding all your code with a catch-all try... except... will silence the error you want to debug. It's unnecessary in general, since Flask will already handle exceptions by showing the debugger or a 500 error and printing the traceback to the console.
You can use app.run(debug=True) for the Werkzeug Debugger edit as mentioned below, and I should have known.
From the 1.1.x documentation, you can enable debug mode by exporting an environment variable to your shell prompt:
export FLASK_APP=/daemon/api/views.py # path to app
export FLASK_DEBUG=1
python -m flask run --host=0.0.0.0
One can also use the Flask Debug Toolbar extension to get more detailed information embedded in rendered pages.
from flask import Flask
from flask_debugtoolbar import DebugToolbarExtension
import logging
app = Flask(__name__)
app.debug = True
app.secret_key = 'development key'
toolbar = DebugToolbarExtension(app)
#app.route('/')
def index():
logging.warning("See this message in Flask Debug Toolbar!")
return "<html><body></body></html>"
Start the application as follows:
FLASK_APP=main.py FLASK_DEBUG=1 flask run
If you're using Visual Studio Code, replace
app.run(debug=True)
with
app.run()
It appears when turning on the internal debugger disables the VS Code debugger.
If you want to debug your flask app then just go to the folder where flask app is. Don't forget to activate your virtual environment and paste the lines in the console change "mainfilename" to flask main file.
export FLASK_APP="mainfilename.py"
export FLASK_DEBUG=1
python -m flask run --host=0.0.0.0
After you enable your debugger for flask app almost every error will be printed on the console or on the browser window.
If you want to figure out what's happening, you can use simple print statements or you can also use console.log() for javascript code.
To activate debug mode in flask you simply type set FLASK_DEBUG=1 on your CMD for windows, or export FLASK_DEBUG=1 on Linux terminal then restart your app and you are good to go!!
Install python-dotenv in your virtual environment.
Create a .flaskenv in your project root. By project root, I mean the folder which has your app.py file
Inside this file write the following:
FLASK_APP=myapp
FLASK_ENV=development
Now issue the following command:
flask run
When running as python app.py instead of the flask command, you can pass debug=True to app.run.
if __name__ == "__main__":
app.run(debug=True)
$ python app.py
with virtual env activate
export FLASK_DEBUG=true
you can configure
export FLASK_APP=app.py # run.py
export FLASK_ENV = "development"
to start
flask run
the result
* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: xxx-xxx-xxx
and if you change
export FLASK_DEBUG=false
* Environment: development
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
For Windows users:
Open Powershell and cd into your project directory.
Use these commandos in Powershell, all the other stuff won't work in Powershell.
$env:FLASK_APP = "app"
$env:FLASK_ENV = "development"
If you have PyCharm Professional, you can create a Flask server run configuration and enable the FLASK_DEBUG checkbox. Go to Run > Edit Configurations, select or create a Flask server configuration, and enable the FLASK_DEBUG checkbox. Click OK, then click the run button.
You can install python-dotenv with
pip install python-dotenv then create a .flask_env or a .env file
The contents of the file can be:
FLASK_APP=myapp
FLASK_DEBUG=True
Use loggers and print statements in the Development Environment, you can go for sentry in case of production environments.

at top of python program, a command "import csv" "is not accessed" where to find it

import csv
fails, alert "csv.py" is not accessed
yes, there is no file of that name in my current working directory.
Where can I locate a copy of csv.py to use in my current project.
import urllib.request, urllib.error, urllib.parse #this command works
import obo #this command works because I have obo.py in my directory
import csv # csv is underlines with white dots, csv is not accessed
where do I seek csv.ph?
running windows Visual Studio version 1.73.1
Newbie error. The warning from Visual Studio only meant that I imported a module but didn't use it in the program.

Import error running pytest - Google Cloud Function

My folder structure is like this
cloud_fn_dir
cf1_dir
main.py
util.py
requirements.txt
test_main_cf1.py
cf2_dir
main.py
requirements.txt
test_main_cf2.py
cf3_dir
main.py
requirements.txt
test_main_cf3.py
I am executing unit tests and generating coverage report using command - pytest -v --cov=main --cov-report=html
If I am executing the command from inside the Cloud function folders i.e. cf1_dir or cf2_dir folders then the pytest command works as expected and executes the unit tests and generates reports inside that folder.
But I wish to execute all the unit tests at once and generate a single report and hence I tried to execute the same command from outermost folder i.e. cloud_fn_dir and encountered Import Error where the test_main_cf3.py file is trying to import Class of cf1_dir main.py file.
Each of the test file is importing it's respective main.py file in it and creates an object and calls the methods to test. So when I execute the pytest command it is making the last test file i.e. test_main_cf3.py to import main of cf1_dir main.py and execute the methods. Pytest is trying to import the first encountered main.py class
How do I resolve this import error ?

Converting python script to exe. Failed to execute script

I have made a game using pygame and now want to convert the script to an exe file. However, when doing this and starting the exe file I get an error saying "Failed to execute script (main.py)". I have tried everything from youtube videos to reading similar questions on Stack Overflow. But nothing works, I get the same error every time. How can I solve this?
Does it have to do something with my imports?
The import that I use in my script:
pygame
random
winsound
mixer (from pygame)
Avoid all of these problems and use PyInstaller (link to related question):
Download this library with pip by typing in the Command Prompt:
py -m pip install pyinstaller
Then, type cd [path to the file].
Finally, type py -m PyInstaller --onefile [script name].py.
PyInstaller will turn your code into one .exe file, in the folder dist, analyzing the modules you need.
After the installation, you can then delete all the other files, like the folder build for example.
If you need other attached files, like images, put them in the folder where the .exe file has been created.
Anyways, if you type exit() anywhere in your code, PyInstaller will raise an error. Simply import sys and type sys.exit() instead.

How to import CSV to KNIME in command line

I want to import a CSV file to KNIME in command line. When I run a command line like this:
"C:\Program Files\KNIME\knime.exe" c:\temp\foo.csv
A dialog pops up, but the button is grayed, I can't click finish. I'm new to KNIME, just installed it, does KNIME support importing CSV directly? Thanks.
That is not how you can import CSV files. That way you can open KNIME workflows. If you want to override a KNIME workflow's input data and (batch) execute the KNIME workflow, you should use flow variables as input and specify them in the command line: https://www.knime.com/faq#q12
-workflow.variable=my_csv_location,C:/tmp/foo.csv,String
Or something similar.
If you just want to import a CSV file to an existing workflow, just drag it on the editor area and it will add a CSV Reader node with the path set.