JPype conflicts with django and raven - django

I am using jpype 0.6.1. I have written a python script to run some piece of code written in scala. Every thing is working as expected. But when I have integrated python script into my django project, I was getting some errors related to raven module.
Scala code to print message :
package com.test.auth
object Auth {
// returns the message passed as parameter
def printMessage(message: String) : String = {
message
}
}
Python script that accesses above code
import jpype
from jpype import *
classpath = '-Djava.class.path=/home/ec2-user/dt/jars/Auth.jar'
jpype.startJVM(jpype.getDefaultJVMPath(),classpath)
authPackage = JPackage('com.test.auth')
Auth = authPackage.Auth
msg = Auth.printMessage("Hello World")
print "message : ",msg
The above code is working fine. but after integrating into django project, I was getting following error
TypeError: Package com.test.auth.Auth.printMessage.__sentry__ is not
Callable 2016-08-16 07:56:08,850 [ERROR]
logger=sentry.errors.serializer process=14605 thread=140040558467072
Package com.test.auth.Auth.printMessage.__sentry__ is not Callable
I am new to django. I have read about the raven logging mechanism. but unable to find the issue.

Looking into this, we're just logging this and this should not interfere with Raven's normal reporting.

I had just the same problem. I manage fix this after putting on the Django project root folder the folder with all .class files that i was using.

Related

how to resolve imports from shared package expo project in a monorepo

I have an import from a shared package of a typescript file inside my mobile package and currently using expo-yarn-workspaces;
import { ButtonStyles } from "#org/shared/components/button";
But then on running expo start --clear --web throws me an error
Module parse failed: Unexpected token (6:7)
You may need an appropriate loader to handle this file type.
| const ButtonTypes = tuple("outlined", "primary", "danger", "link");
Github issue merged here - https://github.com/expo/expo-cli/issues/1080
Due to some reason, we opted out the decision to use react-native itself. So, not tracking myself. Posting if someone finds it relevant for their work.

using nativescript-audio is throwing can not find module error

I want to play mp3 in native script application. and I followed this introduction, https://www.npmjs.com/package/nativescript-audio to install nativescript-audo.
But when I run, I met this error:
file:///app/modules/rss_player/detail.component.js:7:35: JS ERROR Error: Could not find module 'nativescript-audio'
I used this first:
tns plugin add nativescript-audio
then
import { TNSPlayer } from 'nativescript-audio';
this._player = new TNSPlayer();
Can anyone tell me where is the error?
Do I have to import any special module? but which one?
The git for this plugin is:
https://github.com/bradmartin/nativescript-audio/tree/master/demo/app
Thanks

redirecting python import to another module

I'm working on a large open source Python project, which has modules used by both the project and other projects. The goal is to move some of these modules out to a new "library" project that can then be imported by the original project and other projects.
To make this transition smooth, the thought was to copy the modules over to the new project, and have the original project then use the new import. However, to allow other project to have time to migrate later, the thought was to have the original module redirect the import.
For example, the usage is like this in repo 'neutron' (other projects could do the same):
cat neutron/consumer.py
from neutron.redirected import X
print(X)
The in the new 'neutron_lib' project created, the module looks like this (the same as what the original was in project 'neutron'):
cat ../neutron-lib/neutron_lib/redirected.py
X = 5
In the 'neutron' project, I'm trying to do this as the redirect module:
cat neutron/redirected.py
import neutron_lib.redirected
import sys
sys.modules['neutron.redirected'] = neutron_lib.redirected
When I run pylint, it gives these errors:
************* Module neutron.redirected
E: 1, 0: No name 'redirected' in module 'neutron_lib' (no-name-in-module)
************* Module neutron.consumer
E: 1, 0: No name 'X' in module 'neutron.redirected' (no-name-in-module)
If I run this, it runs fine, and consumer.py prints '5'. If I use ipython and load consumer.py, I can see 'X' in dir() output.
Any idea why I'm getting this pylint error? Is it a false error? Is there a way to override it?
Looks like, when running under tox, I can add the following to .pylintrc to hide the errors/warnings
no-name-in-module
nonstandard-exception
When I run pylint it passes now, as does running the Unit tests. Just wish I understood why I'm getting these errors/warnings though.

Python 2.7 : Import a module situated in a subdirectory from a different subdirectory

Here's my code configuration:
__init__py
./module_1/foo.py
./module_1/__init__.py
./module_2/bar.py
./module_2/__init__.py
My goal is to be able to import the foo module from bar.py, but I'm getting quite confused on how to do it.
Something such as:
from ..module_1.foo import *
Will raise the following error:
ValueError: Attempted relative import in non-package
EDIT:
Ideally I'd like to be able to run my script in the following fashion:
python ./module1/foo.py
You haven't shown how you are invoking the script, but you need to ensure that your scripts are actually packages in your python path. That's basically what the error message is telling you, you were trying to import a "non-package". You probably don't have your top-level in the python path. For example ...
If your top-level module is called app and your configuration is
<path-to-app>/app/__init__py
<path-to-app>/app/module_1/foo.py
<path-to-app>/app/module_1/__init__.py
<path-to-app>/app/module_2/bar.py
<path-to-app>/app/module_2/__init__.py
You can run your script as follows.
cd <path-to-app>
PYTHONPATH=$PWD python -m app.module_2.bar
Works for me.

Inside Django tests folder not able to import outer modules

I am trying to create a tests folder in my django app.
My app has following structure:
myapp
myapp/tests/__init__
mtapp/tests/test_email
myapp/function
Now i am trying to import function inside test_email file.
and executing test case as
python manage.py test myapp
but this gives me error No module named function.
Please let me know the reason behind this.
First Edit: if i put "import ..function" then its working fine. but is it a right way to do it.
Note: I am using python version 2.7,
Django version 1.5.5
It might be a case of some Cyclic import when you are using from ...filename import function.
It can be resolved by importing the function locally in the TestCase.