abspath returns different results when py_compile input path is different in Python?

2018-02-12 Thread lampahome
I want to know abspath of python script followed by steps below.

   1. *built it to byte code by py_compile.*
   2. *execute it to check abspath.*

But I got *2 results* when I execute it.I found the *results based on the
path of script* followed by py_compile.

Here is my script test.py :

import osimport inspect
print os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe(

Build it with py_compile, then got 2 results when I enter *different path
of test.py*:

*enter the folder and compile with only script name.*

[~]cd /usr/local/bin/[/usr/local/bin/]python -m py_compile
test.py[/usr/local/bin/]cd ~[~]python
/usr/local/bin/test.pyc/home/UserXX

*In other folder and compile with absolute script name.*

[~]python -m py_compile /usr/local/bin/test.py[~]python
/usr/local/bin/test.pyc/usr/local/bin

how come got 2 different results?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: abspath returns different results when py_compile input path is different in Python?

2018-02-12 Thread eryk sun
On Mon, Feb 12, 2018 at 9:40 AM, lampahome  wrote:
> I want to know abspath of python script followed by steps below.
>
>1. *built it to byte code by py_compile.*
>2. *execute it to check abspath.*
>
> But I got *2 results* when I execute it.I found the *results based on the
> path of script* followed by py_compile.
>
> Here is my script test.py :
>
> import os
> import inspect
> print 
> os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe(
>
> Build it with py_compile, then got 2 results when I enter *different path
> of test.py*:
>
> *enter the folder and compile with only script name.*
>
> [~] cd /usr/local/bin/
> [/usr/local/bin/] python -m py_compile test.py
> [/usr/local/bin/] cd ~
> [~] python /usr/local/bin/test.pyc
> /home/UserXX
>
> *In other folder and compile with absolute script name.*
>
> [~] python -m py_compile /usr/local/bin/test.py
> [~] python /usr/local/bin/test.pyc
> /usr/local/bin

A code object has a co_filename attribute for use in creating
tracebacks. This path isn't necessarily fully qualified. Here are a
couple of examples using the built-in compile() function:

>>> compile('42', 'test.py', 'exec').co_filename
'test.py'
>>> compile('42', '/usr/local/bin/test.py', 'exec').co_filename
'/usr/local/bin/test.py'

py_compile.compile() does not normalize the filename.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] How to set/update value in a xml file using requests in python

2018-02-12 Thread Sum J
Thanks Dan for your response.


I have updated the data to be sent in xml format and now I am able to
update the required fields using put request.

data= '''

  
   web-proxy.xx.com
   8080
   
   on
  
'''


On Thu, Feb 8, 2018 at 10:15 PM, Dan Stromberg  wrote:

> This is more relevant to python-list than python-dev. I've added
> python-list to the To header.
>
> Gmail doesn't appear to allow setting a reply-to for a single message,
> so I've not set that; please, when replying, drop python-dev from the
> to: header.
>
> You'll likely want to set up some kind of REST endpoint to allow
> updating your xml file.  Imagine if anyone could change anyone else's
> xml files - it'd be pretty chaotic.
>
> Perhaps flask would be appropriate?
> http://flask.pocoo.org/docs/0.12/quickstart/
>
> You likely will want a PUT or a POST HTTP verb:
> https://stackoverflow.com/questions/107390/whats-the-
> difference-between-a-post-and-a-put-http-request
>
> HTH.
>
> On Thu, Feb 8, 2018 at 12:38 AM, Sum J  wrote:
> > My xml file is located in local network:
> >
> > http://192.168.43.109/DevMgmt/NetAppsDyn.xml
> >
> > Below is a part content of above xml I want to update :
> >
> > 
> >
> > 
> > 
> > 
> > off
> > 
> >
> > 
> >
> > I want to set the value for 'ResourceUI' and 'Port' field in above xml.
> >
> > I have used below code :
> >
> >  import requests
> >  data = {
> >   'ResourceURI':'web-proxy.xxx.yy.com',
> >   'Port':8080
> > }
> >
> > URL = 'http://192.168.75.165/DevMgmt/NetAppsDyn.xml'
> >
> > # content type
> > head = {'Content-type': 'text/xml'}
> > # sending get request
> > gr= requests.get(url=URL)
> > print gr
> >
> > # sending put request
> > r = requests.put(url=URL, data=data,headers=head)
> > print r.status_code
> > # extracting response text
> > output_xml = r.text
> > print("The op xml is:%s" % output_xml)
> >
> > Issue : The fields are not getting updated in xml using put request. I am
> > able to see the response for get (request) , but for put request it is
> > throwing errror code : 301 , resource has been moved permanently.
> >
> >
> >
> > ___
> > Python-Dev mailing list
> > python-...@python.org
> > https://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe:
> > https://mail.python.org/mailman/options/python-dev/drsalists%40gmail.com
> >
>
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Can't Uninstall !

2018-02-12 Thread Pedro Crescencio
 

 

Hello, 

 

I tried to uninstall Python, but it is not possible.

Even when message say it is uninstalled : 



 

The software is still on applications menu: 



 

How do I do to uninstall it ?

I have the same problem with booth python versions (3.6.4 and 3.7.0b1) and
the Sourcetree of Atlassian.

 

Best regards, 

 

Pedro

 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can't Uninstall !

2018-02-12 Thread Michael F. Stemper

On 2018-02-12 11:54, Pedro Crescencio wrote:


Hello,



I tried to uninstall Python, but it is not possible.

Even when message say it is uninstalled :



The software is still on applications menu:



How do I do to uninstall it ?

I have the same problem with booth python versions (3.6.4 and 3.7.0b1) and
the Sourcetree of Atlassian.


A few questions:

1. Why do you want to uninstall it? What are you trying to
   accomplish by uninstalling it?
2. What operating system are you using?
3. How did you try to uninstall it?
4. What messages did you get when you tried to uninstall it?
5. How did you install two different 3.x versions?

--
Michael F. Stemper
Indians scattered on dawn's highway bleeding;
Ghosts crowd the young child's fragile eggshell mind.
--
https://mail.python.org/mailman/listinfo/python-list


Re: abspath returns different results when py_compile input path is different in Python?

2018-02-12 Thread lampahome
so py_compile.compile() doesn't normalize the filename, but it will pass
the input filename to co_filename?

2018-02-12 19:27 GMT+08:00 eryk sun :

> On Mon, Feb 12, 2018 at 9:40 AM, lampahome  wrote:
> > I want to know abspath of python script followed by steps below.
> >
> >1. *built it to byte code by py_compile.*
> >2. *execute it to check abspath.*
> >
> > But I got *2 results* when I execute it.I found the *results based on the
> > path of script* followed by py_compile.
> >
> > Here is my script test.py :
> >
> > import os
> > import inspect
> > print os.path.dirname(os.path.abspath(inspect.getfile(
> inspect.currentframe(
> >
> > Build it with py_compile, then got 2 results when I enter *different path
> > of test.py*:
> >
> > *enter the folder and compile with only script name.*
> >
> > [~] cd /usr/local/bin/
> > [/usr/local/bin/] python -m py_compile test.py
> > [/usr/local/bin/] cd ~
> > [~] python /usr/local/bin/test.pyc
> > /home/UserXX
> >
> > *In other folder and compile with absolute script name.*
> >
> > [~] python -m py_compile /usr/local/bin/test.py
> > [~] python /usr/local/bin/test.pyc
> > /usr/local/bin
>
> A code object has a co_filename attribute for use in creating
> tracebacks. This path isn't necessarily fully qualified. Here are a
> couple of examples using the built-in compile() function:
>
> >>> compile('42', 'test.py', 'exec').co_filename
> 'test.py'
> >>> compile('42', '/usr/local/bin/test.py', 'exec').co_filename
> '/usr/local/bin/test.py'
>
> py_compile.compile() does not normalize the filename.
>
-- 
https://mail.python.org/mailman/listinfo/python-list