Question around VSCode and Linting.
My Python Folder Structure is as follows:
Python/
|-- common/
| |-- util.py
|
|-- ServiceA/
| |-- requirments.txt
| |-- serviceA/
| | |-- __init__.py
| | |-- MyClass.py
| | |-- main_script.py
|-- ServiceB/
|-- ServiceC/
The goal here is to be able to consume the common package in all the services, and we have some cases that service are reference to another service (We will extract it to other common folder).
To achieve this, i'm setting my PYTHONPATH env var to the root python folder.
In my launch.json file, i'm setting this env var.
I have the following issue/concerns:
When I create an instance of MyClass in the script, and the instance is passed as parameters to the functions, I can't do "go to definition". I assume it's because my workspace folder (ServiceA) is not the same as my PYTHONPATH (Which is the root python folder). Any idea how can I solve this?
In main_script i'm trying to call a method of MyClass which doesn't exists. Should PyLint throw an error that the method doesn't exists? Is it related to PYTHONPATH? How can I see an error in this kind of case (class method don't exists).
Is there some kind of CLI tool to get this kind of errors, to do as part of CI?
Related
I am attempting to create an API wrapper but I am unable to use the wrapper. My __init__.py
from .sb import Skyblock
The folder that contains the module is called skyblock and the file with the Skyblock class is called sb.py
The file I'm trying to use the module in contains this code
from skyblock import *
set_api_key('49baa0d9-ecf3-430d-8669-c08495664889')
uuid = uname_resolver('Metasploitable')
print(get_news())
I am getting an undefined error
Here's the directory structure
C:.
| requirements.txt
| testing.py
|
\---skyblock
| sb.py
| __init__.py
|
\---__pycache__
sb.cpython-37.pyc
__init__.cpython-37.pyc
You are using relative import, so you need to import as
from .skyblock import *
You can refer to this site for more information: PEP-328
I have a dash app which needs to use 2 different css files. One is in the assets folder where the app is located, but the other one sits in a relative path, e.g under common
all_my_apps/
|--app1/
|--app1.py
|--assets/
|-- app1.css
|--app2/
|--app2.py
|--assets/
|-- app2.css
|--common/
|--common.css
I used to be able to do it (in dash 0.4.1) using static_url_path and flask.send_from_directory() which don't work anymore.
You could try symlinking your common.css inside the app asset folders. Something like cd app2/assets && ln -s ../../common/common.css
My JSF web application shows the following error:
/index.xhtml Not Found in ExternalContext as a Resource.
My directory structure is:
- Java Resource
-- src
--- br.com.k19.controle
---- NumeroAleatorioBean.java
--- resources
- JavaScript Resources
- build
- WebContent
-- META-INF
-- Web Pages
--- index.xhtml
--- formulario.xhtml
-- Web-Inf
Where do I need to put my /index.xhtml in this structure?
The WebContent folder represents the web content. You placed the index.xhtml file inside Web Pages subfolder so the right URL would be
http://localhost:8080/ProjectName/Web Pages/index.xhtml
and thus not
http://localhost:8080/ProjectName/index.xhtml
as you seemed to expect.
If you want to have it on the context root, just get rid of the Web Pages folder altogether and move those .xhtml files directly inside WebContent folder, in the same level as META-INF and WEB-INF:
ProjectName
|-- Java Resources
| `-- src
| `-- br.com.k19.controle
| `-- NumeroAleatorioBean.java
|-- resources
|-- JavaScript Resources
|-- build
`-- WebContent
|-- META-INF
|-- WEB-INF
| |-- faces-config.xml
| `-- web.xml
|-- index.xhtml
`-- formulario.xhtml
Note: Java is case sensitive. Web-Inf is definitely not the same as WEB-INF. Be careful or you'll have a security hole.
I faced this issue recently. I tried cleaning the Tomcat Work Directory, Clean, and Publish.
After that, when I started the server, the application was running smooth.
For independent tomcat server, clean dir --> temp, work, and inside webApp directory, remove all the existing unarchived project.
Restart the Tomcat, it worked for me.
I have added a common JAR to my project. The jar looks something like...
CommonWeb.jar
|-- META-INF
| |-- resources
| | `-- common
| | |-- css
| | | `-- my.css
| | |-- js
| | | `-- my.js
| | |-- images
| | | `-- my.png
| | |-- components
| | | `-- mycomposite.xhtml
| | `-- templates
| | `-- mytemplate.xhtml
| |-- faces-config.xml
| `-- MANIFEST.MF
:
Everything is working except that Netbeans will not recognise my composite component. The page trying to use the component looks something like this...
<ui:composition template="/resources/common/templates/mytemplate.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:cmn="http://java.sun.com/jsf/composite/common/components">
<ui:define name="content">
...
<cmn:mycomposite ... />
...
</ui:define>
</ui:composition>
The project will compile and run, no worries. But the IDE gives me red squiggly lines on <cmn:mycomposite ... /> and does not auto-complete, etc. It will all work fine if I copy the component into the project's own resources folder, so it seems netbeans just isn't looking to the jar.
There are quite a few questions around with similar problems, eg:
JSF Composite Component into JAR in NetBeans
JSF Composite Component Netbeans
Composite components in an external JAR are not recognized in
Netbeans
...but there are no satisfactory solutions or workarounds.
Also there have been a few netbeans bug reports on the matter but these all seem to be 'fixed'
Is there some configuration that I'm missing? Has anyone actually managed to get this working with the latest version of NetBeans (NetBeans 7.4 Patch 2 at time of writing)? Has anyone found a work-around that actually works?
UPDATE:
This problem continues to occur in NetBeans 8
This issue is an IDE only issue and continues in version 8.1. It stems from the bug identified in Netbeans bugzilla - specifically in the "JSF Editor for XHTML" module (org.netbeans.modules.web.jsf.editor)
I resolved the issue by downloading the version 8.1 source files for Netbeans and applying the suggested patch myself. I'm guessing it's a similar issue in earlier versions but I didn't check this.
To download and compile Netbeans you can follow the "How To" in here
Changes in summary:
CompositeComponentModel.java line 296 changed to:
if (parent != null && parent.getName().equalsIgnoreCase("META-INF")) { //NOI18N
JsfBinaryIndexer.java line 74 changed to:
namePattern = ".*\\.tld|.*\\.taglib\\.xml|.*\\.xhtml",
Indexer version incremented on line 81 changed to:
static final int INDEXER_VERSION = 11; //NOI18N
Given that the bug is being tracked hopefully it makes it into the next release.
My JSF web application shows the following error:
/index.xhtml Not Found in ExternalContext as a Resource.
My directory structure is:
- Java Resource
-- src
--- br.com.k19.controle
---- NumeroAleatorioBean.java
--- resources
- JavaScript Resources
- build
- WebContent
-- META-INF
-- Web Pages
--- index.xhtml
--- formulario.xhtml
-- Web-Inf
Where do I need to put my /index.xhtml in this structure?
The WebContent folder represents the web content. You placed the index.xhtml file inside Web Pages subfolder so the right URL would be
http://localhost:8080/ProjectName/Web Pages/index.xhtml
and thus not
http://localhost:8080/ProjectName/index.xhtml
as you seemed to expect.
If you want to have it on the context root, just get rid of the Web Pages folder altogether and move those .xhtml files directly inside WebContent folder, in the same level as META-INF and WEB-INF:
ProjectName
|-- Java Resources
| `-- src
| `-- br.com.k19.controle
| `-- NumeroAleatorioBean.java
|-- resources
|-- JavaScript Resources
|-- build
`-- WebContent
|-- META-INF
|-- WEB-INF
| |-- faces-config.xml
| `-- web.xml
|-- index.xhtml
`-- formulario.xhtml
Note: Java is case sensitive. Web-Inf is definitely not the same as WEB-INF. Be careful or you'll have a security hole.
I faced this issue recently. I tried cleaning the Tomcat Work Directory, Clean, and Publish.
After that, when I started the server, the application was running smooth.
For independent tomcat server, clean dir --> temp, work, and inside webApp directory, remove all the existing unarchived project.
Restart the Tomcat, it worked for me.