Re: "import socket" error

2005-10-09 Thread akbar
Fedora Core 4.

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


custom xml pretty print

2005-11-20 Thread akbar
Hi,

I have Document. If I print it like this:

print doc.toprettyxml("  ")

I will get this:

  

  blablablabla

  


What do I have to do if I want to print it like this:

  
blablablabla
  


Thank you.

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


gettext newbie frustration

2006-07-05 Thread akbar
Hi, I try to learn gettext and python. This is the simple program
#simplehello.py
import locale
import gettext

APP = 'simplehello'
DIR = 'locale'
locale.setlocale(locale.LC_ALL, '')
gettext.bindtextdomain(APP, DIR)
gettext.textdomain(APP)
_ = gettext.gettext

print _('Hello World')

After that I do this in my shell:
$ xgettext -k_ -kN_ -o messages.pot simplehello.py
$ cp messages.pot de.po

Edit the de.po so it will be like this:

"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: simplehello.py:11
msgid "Hello World"
msgstr "blabla"

Then...
$ msgfmt de.po -o locale/de/LC_MESSAGES/simplehello.mo
$ msgfmt de.po -o locale/de_DE/LC_MESSAGES/simplehello.mo
$ msgfmt de.po -o locale/de_DE.UTF-8/LC_MESSAGES/simplehello.mo

I try to run the application:
$ LANG=de_DE.UTF-8 python simplehello.py

The output is still 'Hello World' not 'blabla'.
What's wrong?

Additional facts:
$ locale -a
C
de_AT.utf8
de_BE.utf8
de_CH.utf8
de_DE.utf8
de_LU.utf8
en_AU.utf8


$ LANG=de_DE python simplehello.py
Traceback (most recent call last):
  File "simplehello.py", line 6, in ?
locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python2.4/locale.py", line 381, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting

Thank you.

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


should I distribute .pyc files?

2006-12-18 Thread akbar
Hi,

I am creating not-so-important opensource application written in python
for Linux. I have two files python source in src directory, named
blabla1.py and blabla2.py. There are byte compiled files too, named
blabla1.pyc and blabla2.pyc. Should I distribute these files (pyc
files) to users? If I don't distribute them, and user installed my
application into /usr (not writable by normal user) then run it as
normal user, off course, the python cannot make byte-compiled version.
Will my program runs slower in user computer then in my computer
because I have byte compiled version?

Thank you.

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


finding monitor or screen resolution in Linux with standard python module

2007-03-07 Thread akbar
I googled and searched in archive. All I can find is finding
resolution with Tkinter and pygame. Any idea to find monitor
resolution with standard python module?
I can check from output of: xprop -root
_NET_DESKTOP_GEOMETRY(CARDINAL) . The problem is when you use Beryl or
Xgl, it is not correct anymore because Beryl or Xgl set this value
from amount of workspaces multiplied by monitor or screen resolution.

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


Geting error using python 3.5 : a_token = r.json() mention below

2016-12-20 Thread Akbar Shaikh
import io
import csv
import glob
import os.path
import requests
import subprocess
import urllib.request
import json
import time
import xlwt
import xlrd
import datetime
from datetime import date, timedelta

def main():
""" Run the whole toolchain for all accounts. """
_clean()

payload = {'client_id':'' ,
'client_secret':'',
'grant_type':'client_credentials'}
headers1 = {
'Content-Type':'application/json'
}

r = requests.post('https://auth.smaato.com/v2/auth/token/ 
HTTP/1.1',params=payload,auth=('username', 'password'),headers = headers1,)

a_token = r.json()

ACCESSTOKEN = a_token['access_token']
print ('Bearer ' + ACCESSTOKEN)

content2 = {
'client_id':'' ,
'client_secret':'',
'grant_type':'client_credentials',
'Authorization': 'Bearer' + ACCESSTOKEN,
'POST':'https://api.smaato.com/v1/reporting/ HTTP/1.1',
'Content-Type':'application/json',
'Host': 'api.smaato.com',
'criteria':{"dimension":"ApplicationId","child":"null"},
'kpi': {"clicks : true"},

'period':{"period_type":"fixed","start_date":"2016-12-7","end_date":"2016-12-7"}
}

headers2 = {
'client_id':'' ,
'client_secret':'',
'grant_type':'client_credentials',
'Authorization': 'Bearer' + ACCESSTOKEN,
'Username':'Username',
'Password':'Password',
'Content-Type': 'application/json',
'Host': 'api.smaato.com',
}
s = 
requests.post('https://api.smaato.com/v1/reporting/',params=content2,auth=('username',
 'password'), headers = headers2)
print(s.content)
  
def _clean():
""" Cleans old data files.
"""
for f in glob.glob('./Numbers *.csv'):
os.remove(f)

if '__main__' == __name__:
main()
-
Error:  Traceback (most recent call last):
  File "C:\Users\\Desktop\Smaato Akbar.py", line 66, in 
main()
  File "C:\Users\\Desktop\Smaato Akbar.py", line 28, in main
a_token = r.json()
  File 
"C:\Users\xxx\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\models.py",
 line 850, in json
return complexjson.loads(self.text, **kwargs)
  File 
"C:\Users\\AppData\Local\Programs\Python\Python35-32\lib\site-packages\simplejson\__init__.py",
 line 516, in loads
return _default_decoder.decode(s)
  File 
"C:\Users\\AppData\Local\Programs\Python\Python35-32\lib\site-packages\simplejson\decoder.py",
 line 374, in decode
obj, end = self.raw_decode(s)
  File 
"C:\Users\\AppData\Local\Programs\Python\Python35-32\lib\site-packages\simplejson\decoder.py",
 line 404, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
-- 
https://mail.python.org/mailman/listinfo/python-list