These are chat archives for pybee/general

7th
Mar 2017
Elias Dorneles
@eliasdorneles
Mar 07 2017 00:39
@deep110 So, I think you can for now implement just for the object
And then maybe @freakboy3742 can provide an example of some static method call like that, I'm not sure where would be the right place to do it
Maybe there is an example of that somewhere already
Deepankar Agrawal
@deep110
Mar 07 2017 00:43
ya sure
Russell Keith-Magee
@freakboy3742
Mar 07 2017 01:31
@deep110 So - I can think of two ways of tackling @staticmethod and @classmethod
You might be able to work out a pure-python implementation; but the better approach will be to use the AST and inspect specifically for those two decorators, and modify the way the methods are rolled out in response.
Chiang Fong Lee
@cflee
Mar 07 2017 01:43
@freakboy3742 that sounds reasonable, just the latest release for each 3.x version. hopefully that way there won’t be so many if (org.Python.VERSION < 0x3050000) flags, and we can avoid things like that bug in 3.4.2 (fixed in 3.4.3) if we just test against 3.4.5
sdoshi96
@sdoshi96
Mar 07 2017 03:05
Hi! @deep110 , I didn't run the setup.py so it was not working. Thanks for the help , now its working . :)
Hi @dibyadas . I had already activateed the virtual env. I was facing problem as I have not run the setup.py . Thanks for your help:)
Adarsh Sanjeev
@adarshsanjeev
Mar 07 2017 03:50
I am trying to built the project, and on running the django server, the code I type throws error, what can I do?
Muhammad Hashim Shafiq
@hashimshafiq
Mar 07 2017 08:48
Hi ! I hope you all are fine. My name is Muhammad Hashim Shafiq. I am final year student at COMSATS Institute of Information Technology Pakistan. I am doing Bachelors in Computer Science (BSCS). My area of expertise is AI, Machine Learning and Deep Learning. I have worked for 2 startups in the past. One is in New Zealand based and other is Stanford based. I want to participate in GOSC 2017 and I like to work in VOCA.
Jonas Schell
@Ocupe
Mar 07 2017 12:01
@hashimshafiq Welcome :)
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 07 2017 12:45
how to convert any Object to string?
Deepanshu Thakur
@Deepanshu2017
Mar 07 2017 12:46
You mean Python String or Java String?
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 07 2017 12:47
no
Like list to string
i think i str() can be used
Deepanshu Thakur
@Deepanshu2017
Mar 07 2017 12:47
from org.python.Object to String you can try something like this objName.__repr__().toString()
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 07 2017 12:48
I dont think it works for strings having UTF-32 character
I am trying to implement ascii() methos
when repr() method is used on a string containing UTF-32 characters, it prints something(weird characters) whereas, in Python it gives an error
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 07 2017 12:54
try : s = 'hello\U0001D11A'
srknkrn
@srknkrn
Mar 07 2017 13:36
Hello guys, I got an error like this *( File "/Users/serkankurun/Desktop/projeler/notifox/toga/lib/python3.6/site-packages/toga/interface/app.py", line 51, in open_document
raise NotImplementedError('Application class must define open_document()'))when I run the toga under macOS 12.12 with python3.6
is there anyone to know what happened?
Deepankar Agrawal
@deep110
Mar 07 2017 13:38
@srknkrn I don't know about toga, but seeing the error, it seems that whatever feature you are trying to use is not implemented.
srknkrn
@srknkrn
Mar 07 2017 13:40
@deep110 thank you, I just wanted to test toga-demo, I newbie :) I'll find out what happened
pravesh kumar shukla
@pravesh98
Mar 07 2017 14:36
Hello guys!
My name is pravesh shukla , Final year student from computer science .I want to participate in GSOC 2017.
Haven't did anything great yet as recently got addicted to coding
But have done projects based on Java,(so have good understanding of it) and my final year project is on python,Machine learning , So have a better understanding of python.Earlier have worked on python Opencv, Django
pravesh kumar shukla
@pravesh98
Mar 07 2017 14:42
Also have experience with Windows and Linux,But currently working on Windows
Dibya Prakash Das
@dibyadas
Mar 07 2017 14:45
Hi @pravesh98 ! You can go through the instructions on setting up the environment for working with VOC and also go through the tutorials to get a basic understanding of how VOC works.
Here is the link : - https://voc.readthedocs.io/en/latest/
:smile:
pravesh kumar shukla
@pravesh98
Mar 07 2017 14:46
@dibyadas dude going through that , and what else do i do ?
Dibya Prakash Das
@dibyadas
Mar 07 2017 14:48
@pravesh98 try to fix some issues :smile:
Chiang Fong Lee
@cflee
Mar 07 2017 14:48
@pravesh98 You could have a look at the main BeeWare contributors guide as well: http://pybee.org/contributing/how/first-time/
pravesh kumar shukla
@pravesh98
Mar 07 2017 14:51
@cflee yes dude had gone through it
Chiang Fong Lee
@cflee
Mar 07 2017 14:52
@pravesh98 great!
Adarsh Sanjeev
@adarshsanjeev
Mar 07 2017 14:54
Hi to all! My name is Adarsh Sanjeev, I am studying at International Institute of Information Technology, Hyderabad. I mainly use python to code. I am interested in participating in GSOC'17 for Batavia.
Dibya Prakash Das
@dibyadas
Mar 07 2017 14:58
@cflee if i wanted to create a new python function of my own(lets say, for testing purpose) , i would have to add the function in the common/org/Python.java , right?
or is it something else?
Chiang Fong Lee
@cflee
Mar 07 2017 15:06
@dibyadas what do you mean by that?
org.Python is usually all the builtin functions
then org.python.types.* is where all the basic types live. I’m not sure what sort of function you’re looking for?
Dibya Prakash Das
@dibyadas
Mar 07 2017 15:08

@cflee suppose i want to add a function named test() which return a python string object 'tested' :-

c = test()
print(c)

the output should be :-
tested

this is just for testing purpose
i want to get a complete understanding of the internal working of VOC
which file should i modify for that?
Chiang Fong Lee
@cflee
Mar 07 2017 15:09
well, depends on how/what you want to test… one option is to implement it as a builtin function in org.Python, another is to add a test case somewhere, then you can define it as a python function
those would exercise rather different parts of voc
pravesh kumar shukla
@pravesh98
Mar 07 2017 15:10
yes @cflee even i am interested i knowing the internal working of VOC where do i look into ?
Chiang Fong Lee
@cflee
Mar 07 2017 15:11
if you want to investigate voc handling calls to python builtins - it’d be the former.
if you want to see voc translating the python function definition to a java method - then the latter.
it really depends on what you’re trying to do
Dibya Prakash Das
@dibyadas
Mar 07 2017 15:12
oh! cool..
@cflee thanks a lot!
Chiang Fong Lee
@cflee
Mar 07 2017 15:13
@dibyadas no problem!
Dibya Prakash Das
@dibyadas
Mar 07 2017 15:15
@cflee .. worked!
Adarsh Sanjeev
@adarshsanjeev
Mar 07 2017 15:23
Hi, I am trying to built Batavia, and I have followed all the steps with no error, however it shows an error on most inputs. I have tried the trouble shooting guide, but nothing has worked so far. How could I troubleshoot this? Thank you!
Jacob Stoebel
@jstoebel
Mar 07 2017 15:41
@freakboy3742 I found a college student who is interested in GSoC with this project. Do you have any sway in who gets in? I'd like to put in a good word for him if so. Let me know if it makes sense to talk on a private channel.
Adarsh Sanjeev
@adarshsanjeev
Mar 07 2017 16:27
Hey, I am still having the issue, so I compiled all the debug information I could find. Could anyone offer any advice?

Information:
Archlinux, node 6.9.4, npm3 4.3.0

Error:
print("A")

Traceback (most recent call last):
File "/tmp/tmp6u8zis9f", line 1, in <module>
NameError: name 'undefined' is not defined

Run sample.py
Traceback (most recent call last):
File "sample.py", line 1, in <module>
TypeError: TypeError: args[4] is undefined

srknkrn
@srknkrn
Mar 07 2017 16:28
Hey guys(again :)) Is there anyone who experienced on VOC? I wonder what could be done with VOC? For example, I want to build a some kind of notification handler for my users, and it will be work like a timer, is it possible in VOC?
Elias Dorneles
@eliasdorneles
Mar 07 2017 16:35
@srknkrn VOC turns Python into Java classes, so you can do anything you can do from Java.
For example, here is an Android app I made recently using it: https://github.com/eliasdorneles/tictactoe-voc
srknkrn
@srknkrn
Mar 07 2017 16:42
wow very cool, thank you @eliasdorneles , but i have concerns about VOC because of this paragraph from pybee
It isn't a completely compliant Python 3.4 implementation - there are some language features (like generators and context managers) that still need to be implemented, and there is only a bare bones standard library implementation. However, it is possible to convert simple Python programs, and even write simple Android applications.
Dibya Prakash Das
@dibyadas
Mar 07 2017 17:18

hi @eliasdorneles .. i cannot run the tests found in the voc/tests/ directory.. it gives me an error

  File "test_str.py", line 1, in <module>
    from .. utils import TranspileTestCase, UnaryOperationTestCase, BinaryOperationTestCase, InplaceOperationTestCase
SystemError: Parent module '' not loaded, cannot perform relative import

any pointers on this ? i think i am missing something

Elias Dorneles
@eliasdorneles
Mar 07 2017 18:02
@srknkrn yes, there are many missing features still, BUT, that description was outdated -- we already have generators and context managers working for 90% of the cases :)
@dibyadas hm, are you using a virtualenv? have you installed VOC inside of it?
Dibya Prakash Das
@dibyadas
Mar 07 2017 18:07
@eliasdorneles yes .. i am using virtualenv and installed VOC inside it too....
actually i have already made some fixes and made a PR.. everything works as expected , but this doesn't run
dgelessus
@dgelessus
Mar 07 2017 18:14
@dibyadas How are you running the test script? The error about the relative import indicates that you're running it directly as a script (using python3 voc/tests/test_str.py or something like that). You could try running it as a module (like python3 -m voc.tests.test_str). I think if you run it that way, the relative import will work. (I might be wrong though.)
Dibya Prakash Das
@dibyadas
Mar 07 2017 18:16
@dgelessus yes.. i was running it directly as a script... let me try in the way you said...
this gave me :-
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/dibya/workspace/voc_ws/voc/tests/datatypes/test_str.py", line 1, in <module>
    from .. utils import TranspileTestCase, UnaryOperationTestCase, BinaryOperationTestCase, InplaceOperationTestCase
dgelessus
@dgelessus
Mar 07 2017 18:25
Ah, it seems I was wrong. That looks like the same error as before (just with a few extra lines from runpy).
If the tests are written with the unittest module, I think you can run them with python3 -m unittest voc.tests.test_str. Maybe that way the relative import will work.
Dibya Prakash Das
@dibyadas
Mar 07 2017 18:30
@dgelessus let me see
Dibya Prakash Das
@dibyadas
Mar 07 2017 18:36

@dgelessus that gave an error too.. the same one...

from .. utils import TranspileTestCase, UnaryOperationTestCase, BinaryOperationTestCase, InplaceOperationTestCase
SystemError: Parent module '' not loaded, cannot perform relative import

i'm thinking , it has something to do with this line:-
from .. utils import TranspileTestCase, UnaryOperationTestCase, BinaryOperationTestCase, InplaceOperationTestCase

Elias Dorneles
@eliasdorneles
Mar 07 2017 18:37
so, there are mainly two ways of running the tests...
one of them is using pytest, for which you can give a filename, as in: py.test -s -v tests/builtins/test_str.py
you should run it from inside the directory of the VOC project
the other way of running it is using python setup.py test -s tests.builting.test_str
Dibya Prakash Das
@dibyadas
Mar 07 2017 18:40
@eliasdorneles thanks! . let me run it and see.
Elias Dorneles
@eliasdorneles
Mar 07 2017 18:40
So, I wanted to share this thing I just made: https://gist.github.com/eliasdorneles/59f441bb80618886f00b7c4e336814e6 :)
I wanted a REPL, but building a real one is too much work, and I just wanted an easier way of trying things, so I made a script
Dibya Prakash Das
@dibyadas
Mar 07 2017 18:43
thanks! @eliasdorneles @dgelessus ... it's working :smile:
Elias Dorneles
@eliasdorneles
Mar 07 2017 18:47
good!
Jonas Schell
@Ocupe
Mar 07 2017 19:28
@srknkrn Did you clone toga from GitHub or did you get it from PyPi? If you got it from GitHub than there is a bug that can easily be fixed with this PR pybee/toga#105
Avikant Saini
@avikantz
Mar 07 2017 19:57
@eliasdorneles Since the built in function max in python can take variable number of arguments, Would it be better to map it to a org.python.types.Tuple varargs in Java? I'm using an iterable org.python.Object currently, and it's not giving the desired output for all cases.
Elias Dorneles
@eliasdorneles
Mar 07 2017 19:57
hmm, can you perhaps share what you have so far?
I don't see how mapping to a tuple will help
Avikant Saini
@avikantz
Mar 07 2017 19:58
public static org.python.Object max(org.python.Object iterable) {
        // throw new org.python.exceptions.NotImplementedError("Builtin function 'max' not implemented");
        if (iterable == null) {
            throw new org.python.exceptions.TypeError("max expected 1 arguments, got 0");
        } else {
            org.python.Iterable iterator = org.Python.iter(iterable);
            java.util.List<org.python.Object> lst = new java.util.ArrayList<org.python.Object>();
            try {
                while (true) {
                    org.python.Object temp = iterator.__next__();
                    lst.add(temp);
                }
            } catch (org.python.exceptions.StopIteration si) {
            }
            org.python.Object max = java.util.Collections.max(lst, null);
            return max;
        }
    }
Elias Dorneles
@eliasdorneles
Mar 07 2017 19:59
can you share the signature annotation?
Avikant Saini
@avikantz
Mar 07 2017 19:59
@org.python.Method(
        __doc__ = "max(iterable, *[, default=obj, key=func]) -> value" +
            "max(arg1, arg2, *args, *[, key=func]) -> value\n" +
            "\n" +
            "With a single iterable argument, return its biggest item. The\n" +
            "default keyword-only argument specifies an object to return if\n" +
            "the provided iterable is empty.\n" +
            "With two or more arguments, return the largest argument.\n",
        args={"iterable"}
    )
This?
Elias Dorneles
@eliasdorneles
Mar 07 2017 19:59
Right
Hm, yea, max is a trick one to map...
because it can take both variable arguments and keyword arguments
I think the signature will need to be something like:
@org.python.Method(
    __doc__ = "...",
    args = {"first"},
    varargs = "rest",
    kwargs = "kwargs"
)
public static org.python.Object max(org.python.Object first, org.python.Object rest, org.python.types.Tuple rest, org.python.types.Dict kwargs) {
    // in here you'd have to check if kwargs has one ot the keys "key" or "default", defined
   // and also check if there is anything in the rest argument
}
Elias Dorneles
@eliasdorneles
Mar 07 2017 20:05
makes sense?
Avikant Saini
@avikantz
Mar 07 2017 20:05
Yeah, quite; Thanks.
There'll be only one rest of the type Tuple though, right?
Muhammad Hashim Shafiq
@hashimshafiq
Mar 07 2017 20:22
@eliasdorneles
@eliasdorneles
@eliasdorneles why it is not adding default main method ?
Elias Dorneles
@eliasdorneles
Mar 07 2017 20:31
sorry, I don't follow, how do you mean?
Muhammad Hashim Shafiq
@hashimshafiq
Mar 07 2017 20:33
I follow tutorials how to compile with VOC. But When I try to run it through java it says no main method found
When I see verbose output of tutorial there is a line stating "adding default main method" but in my verbose output it is not mentioned thats why it produces error like no main method found
Jonas Schell
@Ocupe
Mar 07 2017 20:49
@eliasdorneles Do we use Unittest for all of PyBee?
I would like to write some test for toga but there is nothing in place yet.
Russell Keith-Magee
@freakboy3742
Mar 07 2017 23:29
@jstoebel Awesome - and we (BeeWare) get to rank our preferred candidates for GSoC. If you want to put in a good word for someone, go right ahead (feel free to use a private chat if you want)
@Ocupe Yes - we use unittest. And tests for toga are definitely on the “want” list. Just trying to work out what that would look like.
There’s effectively 2 sets of tests needed - Tests that validate that the interface behaves as it should, and tests that platforms implement the interface correctly.
Jacob Stoebel
@jstoebel
Mar 07 2017 23:30
@freakboy3742 thanks for that info. I am speaking with him tomorrow to see if he is interested. I'll PM you if he is.
Russell Keith-Magee
@freakboy3742
Mar 07 2017 23:35
@Ocupe I’m also very interested in making sure that we can offer a good way to test Toga apps - testing mobile/desktop apps has historically been a bit of a black art, relying on robot control of UIs, screenshots and the like. I’ve had this vague thought about a “dummy” backend that would enable you to run tests without anything displaying on the screen.
Jonas Schell
@Ocupe
Mar 07 2017 23:37
@freakboy3742 I agree, the I’m writing test for the interface part at the moment. But only for myself because the Settings API is trickier as I thought it would be.
@freakboy3742 Interesting idea. Would make thinks a lot nicer and stabler to test, I guess.
Russell Keith-Magee
@freakboy3742
Mar 07 2017 23:39
@Ocupe That’s the idea. I’m a big testing nut from way back, and GUI testing has always been a thorn in my side.
I think it’s a place where Toga has the potential to make a huge impact.
Jonas Schell
@Ocupe
Mar 07 2017 23:40
I’m looking forward to see what black magic you come up with :D
freakboy3742 @freakboy3742 goes back to his bubbling cauldron...
Jonas Schell
@Ocupe
Mar 07 2017 23:41
Let me know if you have something I would like to take it for a test ride.
@freakboy3742 Regarding the Settings API. I have the problem that iOS requires you to build your settings.bundle before runtime. Do you think there is a way to hook it into briefcase and create it when you also create the iOS app?
Jacob Stoebel
@jstoebel
Mar 07 2017 23:59
@freakboy3742 stirs cauldron "wing of bee and hair of yak..."