Skip to content

Instantly share code, notes, and snippets.

View Eugeny's full-sized avatar

Eugene Eugeny

View GitHub Profile
#!/usr/bin/python
# -*- coding: utf-8 -*-
from xlrd import *
import sys
import re
reload(sys)
sys.setdefaultencoding('utf-8')
eugeny@eugeny-desktop ~/.gvfs/sftp пользователя root на 10.10.1.1/home/www/phpBB/styles/610nm/template $ lsattachment.html jumpbox.html mcp_logs.html mcp_warn_front.html memberlist_search.html posting_buttons.html search_results.html ucp_header.html ucp_pm_viewfolder.html ucp_register.html
bbcode.html login_body.html mcp_message.html mcp_warn_list.html memberlist_view.html posting_poll_body.html simple_footer.html ucp_main_bookmarks.html ucp_pm_viewmessage.html ucp_remind.html
breadcrumbs.html login_forum.html mcp_move.html mcp_warn_post.html message_body.html posting_preview.html simple_header.html ucp_main_drafts.html ucp_pm_viewmessage_print.html ucp_resend.html
confirm_body.html mcp_approve.html mcp_notes_front.html mcp_warn_user.html overall_footer.html posting_progr
eugeny@eugeny-desktop ~/Work/ajenti (testing) $ git diff 0.3.1...HEAD --stat
.gitignore | 5 +
COPYRIGHT | 90 +++++-
LICENSE | 165 +++++++++
README | 2 +-
ajenti.conf | 2 +-
ajenti/app/application.py | 13 +-
ajenti/com.py | 3 +
ajenti/daemon.py | 255 +++++++-------
ajenti/error.py | 23 +-
eugeny@eugeny-desktop ~/Work/bsuir-connect (newdesign) $ git diff 969f8444...HEAD --stat
.gitignore | 1 +
css/dashboard.css | 45 +--------
css/leftbar.css | 14 ++-
css/messages.css | 14 ++-
css/profile.css | 46 +++++++++
css/registration.css | 12 ++
css/style.css | 196 +++++++++++++++++++++---------------
css/timetable.css | 10 ++-
friends.php | 72 +++++++++++++
u'<span style="font-family: monospace">fsck from util-linux-ng 2.17.2\r<br/>fsck from util-linux-ng 2.17.2\r<br/>/dev/sda7: clean, 233108/1602496 files, 2536539/6400000 blocks\r<br/>/dev/sda1: clean, 420/51272 files, 35431/102400 blocks\r<br/>init: ureadahead-other main process (986) terminated with status 4\r\r<br/> * Setting sensors limits \x1b[80G \r\x1b[74G[ OK ]\r<br/> * Starting virtual private network daemon(s)... \x1b[80G Starting nginx: nginx.\r<br/> * Starting VirtualBox kernel modules \x1b[80G </span>'
class Element(etree.ElementBase):
def __init__(self, tag, *args, **kwargs):
... blah-blah ...
def __setitem__(self, idx, val):
try:
self.set(idx, fix_unicode(val))
except:
print repr(val)
File "/home/eugeny/Work/ajenti/ajenti/ui/classes.py", line 23, in __setitem__
self.set(idx, s)
File "lxml.etree.pyx", line 634, in lxml.etree._Element.set (src/lxml/lxml.etree.c:31912)
File "apihelpers.pxi", line 488, in lxml.etree._setAttributeValue (src/lxml/lxml.etree.c:13918)
File "apihelpers.pxi", line 1295, in lxml.etree._utf8 (src/lxml/lxml.etree.c:20212)
ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes
import random
from lxml import etree
from ajenti.utils import fix_unicode
class Element(etree.ElementBase):
def __init__(self, tag, *args, **kwargs):
etree.ElementBase.__init__(self)
self.tag = tag
from lxml import etree #python-lxml
e = etree.ElementBase()
s = open('/var/log/boot.log').read()
print repr(s)
s = str(s).encode('utf-8', 'xmlcharrefreplace')
print repr(s)
e.set('attr', s)
print repr(e.get('attr'))
def fix_unicode(s):
d = ''
for i in range(0, len(s)):
if ord(s[i])<32:
d += ' '
else:
d += s[i]
return unicode(d, errors='replace')