本文整理汇总了Python中sugar3.profile.get_nick_name函数的典型用法代码示例。如果您正苦于以下问题:Python get_nick_name函数的具体用法?Python get_nick_name怎么用?Python get_nick_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_nick_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _comment_activate_cb
def _comment_activate_cb(self, entry):
text = entry.props.text
if not 'comments' in self._reflection.data:
self._reflection.data['comments'] = []
data = {'nick': profile.get_nick_name(),
'color': self._reflection.activity.fg_color.get_html(),
'comment': text}
self._reflection.data['comments'].append(data)
self.add_new_comment(data)
# Send the comment
if self._reflection.activity.sharing:
send_data = data.copy()
send_data["obj_id"] = self._reflection.data["obj_id"]
self._reflection.activity.send_event(COMMENT_CMD, send_data)
entry.set_text('')
# Update journal entry
dsobj = datastore.get(self._reflection.data['obj_id'])
if 'comments' in dsobj.metadata:
data = json.loads(dsobj.metadata['comments'])
else:
data = []
data.append({'from': profile.get_nick_name(),
'message': text,
'icon-color': profile.get_color().to_string()})
dsobj.metadata['comments'] = json.dumps(data)
datastore.write(dsobj,
update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb)
开发者ID:AbrahmAB,项目名称:reflect,代码行数:31,代码来源:reflectwindow.py
示例2: _comment_activate_cb
def _comment_activate_cb(self, entry):
text = entry.props.text
if not "comments" in self._reflection.data:
self._reflection.data["comments"] = []
data = {
"nick": profile.get_nick_name(),
"color": self._reflection.activity.fg_color.get_html(),
"comment": text,
}
self._reflection.data["comments"].append(data)
self.add_new_comment(data)
# Send the comment
if self._reflection.activity.sharing:
self._reflection.activity.send_event(
"%s|%s|%s|%s|%s"
% (COMMENT_CMD, self._reflection.data["obj_id"], data["nick"], data["color"], data["comment"])
)
entry.set_text("")
# Update journal entry
dsobj = datastore.get(self._reflection.data["obj_id"])
if "comments" in dsobj.metadata:
data = json.loads(dsobj.metadata["comments"])
else:
data = []
data.append({"from": profile.get_nick_name(), "message": text, "icon-color": profile.get_color().to_string()})
dsobj.metadata["comments"] = json.dumps(data)
datastore.write(
dsobj,
update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb,
)
开发者ID:samdroid-apps,项目名称:reflect,代码行数:33,代码来源:reflectwindow.py
示例3: __start_teacher_cb
def __start_teacher_cb(self, button=None):
if self._service is None:
# get a free port
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
sock.bind(('', 0))
sock.listen(socket.SOMAXCONN)
_ipaddr, self.port = sock.getsockname()
sock.shutdown(socket.SHUT_RDWR)
logging.error('Using port %d', self.port)
# puvblish the server direction
self._service = ZeroconfService(name="Teacher", port=self.port,
text=profile.get_nick_name())
logging.error('Publish teacher zeroconf service')
self._service.publish()
# start the http server
httpd = MyHTTPServer(('', self.port),
lambda *args: TeacherRequestHandler(
self._show_received_student_info, *args))
from threading import Thread
self._server = Thread(target=httpd.serve_forever)
self._server.setDaemon(True)
self._server.start()
logging.debug("After start server")
else:
logging.error('Unpublish teacher zeroconf service')
self._service.unpublish()
self._service = None
self._server.stop()
开发者ID:godiard,项目名称:classroomexplore,代码行数:33,代码来源:activity.py
示例4: default_nicks
def default_nicks():
try:
nicks = [conf.get('nick')] + conf.get('altnicks', [])
if not nicks[0]:
# We're going to generate a nick based on the user's nick name
# and their public key.
from sugar3 import profile
import hashlib
user_name = profile.get_nick_name()
pubkey = profile.get_pubkey()
m = hashlib.sha1()
m.update(pubkey)
hexhash = m.hexdigest()
# Okay. Get all of the alphabetic bits of the username:
user_name_letters = "".join([x for x in user_name if x.isalpha()])
# If that came up with nothing, make it 'XO'. Also, shorten it
# if it's more than 11 characters (as we need 5 for - and the
# hash).
if len(user_name_letters) == 0:
user_name_letters = "XO"
if len(user_name_letters) > 11:
user_name_letters = user_name_letters[0:11]
# Finally, generate a nick by using those letters plus the first
# four hash bits of the user's public key.
user_nick = user_name_letters + "-" + hexhash[0:4]
nicks = [user_nick]
except:
nicks = ["purk"]
return nicks
开发者ID:i5o,项目名称:irc-activity,代码行数:35,代码来源:irc.py
示例5: __init__
def __init__(self, handle):
""" Initialize the toolbars and the game board """
try:
super(FlipActivity, self).__init__(handle)
except dbus.exceptions.DBusException as e:
_logger.error(str(e))
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self.colors = profile.get_color().to_string().split(',')
else:
self.colors = ['#A0FFA0', '#FF8080']
self._setup_toolbars()
self._setup_dispatch_table()
# Create a canvas
canvas = Gtk.DrawingArea()
canvas.set_size_request(Gdk.Screen.width(),
Gdk.Screen.height())
self.set_canvas(canvas)
canvas.show()
self.show_all()
self._game = Game(canvas, parent=self, colors=self.colors)
self._setup_presence_service()
if 'dotlist' in self.metadata:
self._restore()
else:
self._game.new_game()
开发者ID:sugarlabs,项目名称:flip,代码行数:31,代码来源:FlipActivity.py
示例6: _start_all_cb
def _start_all_cb(self, widget):
win = str(self.socket.get_id())
if (win.endswith("L")): # L of "Long"
win = win[:-1]
# Run game
command = os.path.join(self._bundle_path, "res/sim") #'SugarCity')
args = [
command,
#'-R', win, # Set root window to socket window id
'-t', # Interactive tty mode, so we can send it commands.
]
self._process = subprocess.Popen(args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
close_fds=True,
cwd=self._bundle_path,
preexec_fn=lambda: os.chdir(self._bundle_path))
self._stdout_thread = thread.start_new(self._stdout_thread_function, ())
uri = self._handle.uri or ''
self.send_process('SugarStartUp "' + QuoteTCL(uri) + '"\n')
nick = profile.get_nick_name() or ''
self.send_process('SugarNickName "' + QuoteTCL(nick) + '"\n')
开发者ID:sugarlabs,项目名称:sugarcity-activity,代码行数:29,代码来源:sugarcityactivity.py
示例7: start_game
def start_game(self, numPlayers):
self._create_domino()
self.placed_pieces = []
self.players = []
auto_player = SimpleAutoPlayer(self, 0)
auto_player.set_pieces(self.take_pieces(7))
self.players.append(auto_player)
if self.ENABLE_AUTO_MODE:
auto_player2 = SimpleAutoPlayer(self, 1)
auto_player2.set_pieces(self.take_pieces(7))
auto_player2.pieces_position = self.table.second_player_position
self.players.append(auto_player2)
else:
for n in range(1, numPlayers):
player = DominoPlayer(self, n)
player.set_pieces(self.take_pieces(7))
self.players.append(player)
# comienza a jugar el primer jugador
self.players[0].play()
self.ui_player = self.players[1]
self.ui_player.color = profile.get_color()
self.ui_player.name = profile.get_nick_name()
self._actual_player = 0
开发者ID:godiard,项目名称:domino-activity,代码行数:25,代码来源:dominogame.py
示例8: __init__
def __init__(self, handle):
""" Initialize the toolbars and the game board """
super(PathsActivity, self).__init__(handle)
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self.colors = profile.get_color().to_string().split(',')
else:
self.colors = ['#A0FFA0', '#FF8080']
self._setup_toolbars()
self._setup_dispatch_table()
# Create a canvas
canvas = Gtk.DrawingArea()
canvas.set_size_request(Gdk.Screen.width(), Gdk.Screen.height())
self.set_canvas(canvas)
canvas.show()
self.show_all()
self._game = Game(canvas, parent=self, colors=self.colors)
self._setup_presence_service()
# Restore game state from Journal or start new game
if 'deck' in self.metadata:
self._restore()
else:
self._game.new_game()
开发者ID:leonardcj,项目名称:paths,代码行数:28,代码来源:PathsActivity.py
示例9: __init__
def __init__(self, handle):
""" Initialize the toolbars and the game board """
try:
super(XOEditorActivity, self).__init__(handle)
except dbus.exceptions.DBusException as e:
_logger.error(str(e))
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self.colors = profile.get_color().to_string().split(',')
else:
self.colors = ['#A0FFA0', '#FF8080']
self.level = 0
self._setup_toolbars(_have_toolbox)
# Create a canvas
canvas = Gtk.DrawingArea()
canvas.set_size_request(Gdk.Screen.width(),
Gdk.Screen.height())
self.set_canvas(canvas)
canvas.show()
self.show_all()
self._game = Game(canvas, parent=self, mycolors=self.colors)
# Read the dot positions from the Journal
for i in range(len(colors)):
if 'x%d' % (i) in self.metadata and 'y%d' % (i) in self.metadata:
self._game.move_dot(i, int(self.metadata['x%d' % (i)]),
int(self.metadata['y%d' % (i)]))
if 'xox' in self.metadata and 'xoy' in self.metadata:
self._game.move_xo_man(int(self.metadata['xox']),
int(self.metadata['xoy']))
开发者ID:sugarlabs,项目名称:xocolors,代码行数:35,代码来源:XOEditorActivity.py
示例10: __init__
def __init__(self, handle):
""" Initialize the toolbars and the game board """
super(RecallActivity, self).__init__(handle)
self.path = activity.get_bundle_path()
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self.colors = profile.get_color().to_string().split(",")
else:
self.colors = ["#A0FFA0", "#FF8080"]
self._restoring = False
self._setup_toolbars(True)
self._setup_dispatch_table()
# Create a canvas
canvas = Gtk.DrawingArea()
canvas.set_size_request(Gdk.Screen.width(), Gdk.Screen.height())
self.set_canvas(canvas)
canvas.show()
self.show_all()
self._game = Game(canvas, parent=self, path=self.path, colors=self.colors)
self._setup_presence_service()
if "dotlist" in self.metadata:
self._restore()
else:
self._game.new_game()
开发者ID:cristian99garcia,项目名称:recall,代码行数:30,代码来源:RecallActivity.py
示例11: __init__
def __init__(self, handle):
''' Initiate activity. '''
super(FractionBounceActivity, self).__init__(handle)
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self._colors = profile.get_color().to_string().split(',')
else:
self._colors = ['#A0FFA0', '#FF8080']
self.max_participants = 4 # sharing
self._playing = True
self._setup_toolbars()
self._setup_dispatch_table()
canvas = self._setup_canvas()
# Read any custom fractions from the project metadata
if 'custom' in self.metadata:
custom = self.metadata['custom']
else:
custom = None
self._current_ball = 'soccerball'
self._toolbar_was_expanded = False
# Initialize the canvas
self._bounce_window = Bounce(canvas, activity.get_bundle_path(), self)
Gdk.Screen.get_default().connect('size-changed', self._configure_cb)
# Restore any custom fractions
if custom is not None:
fractions = custom.split(',')
for f in fractions:
self._bounce_window.add_fraction(f)
if self.shared_activity:
# We're joining
if not self.get_shared():
xocolors = XoColor(profile.get_color().to_string())
share_icon = Icon(icon_name='zoom-neighborhood',
xo_color=xocolors)
self._joined_alert = NotifyAlert()
self._joined_alert.props.icon = share_icon
self._joined_alert.props.title = _('Please wait')
self._joined_alert.props.msg = _('Starting connection...')
self._joined_alert.connect('response', self._alert_cancel_cb)
self.add_alert(self._joined_alert)
self._label.set_label(_('Wait for the sharer to start.'))
# Wait for joined signal
self.connect("joined", self._joined_cb)
self._setup_sharing()
开发者ID:leonardcj,项目名称:fractionbounce,代码行数:57,代码来源:FractionBounceActivity.py
示例12: _get_identifier
def _get_identifier():
path = None
if os.path.exists(SN_PATH_X86):
path = SN_PATH_X86
elif os.path.exists(SN_PATH_ARM):
path = SN_PATH_ARM
if path is not None:
with open(path, 'r') as file:
return file.read().rstrip('\0\n')
return profile.get_nick_name()
开发者ID:curiousguy13,项目名称:sugar,代码行数:10,代码来源:volume.py
示例13: add_bookmark
def add_bookmark(self, page):
bookmark_title = (_("%s's bookmark") % profile.get_nick_name())
bookmark_content = (_("Bookmark for page %d") % (int(page) + 1))
dialog = BookmarkAddDialog(
parent_xid=self.get_toplevel().get_window(),
dialog_title=_("Add notes for bookmark: "),
bookmark_title=bookmark_title,
bookmark_content=bookmark_content, page=page,
sidebarinstance=self)
dialog.show_all()
开发者ID:samdroid-apps,项目名称:read-activity,代码行数:10,代码来源:bookmarkview.py
示例14: register_laptop
def register_laptop(url=_REGISTER_URL):
profile = get_profile()
if _have_ofw_tree():
sn = _read_mfg_data(os.path.join(_OFW_TREE, _MFG_SN))
uuid_ = _read_mfg_data(os.path.join(_OFW_TREE, _MFG_UUID))
elif _have_proc_device_tree():
sn = _read_mfg_data(os.path.join(_PROC_TREE, _MFG_SN))
uuid_ = _read_mfg_data(os.path.join(_PROC_TREE, _MFG_UUID))
else:
sn = _generate_serial_number()
uuid_ = str(uuid.uuid1())
sn = sn or 'SHF00000000'
uuid_ = uuid_ or '00000000-0000-0000-0000-000000000000'
nick = get_nick_name()
settings = Gio.Settings('org.sugarlabs.collaboration')
jabber_server = settings.get_string('jabber-server')
_store_identifiers(sn, uuid_, jabber_server)
if jabber_server:
url = 'http://' + jabber_server + ':8080/'
if sys.hexversion < 0x2070000:
server = xmlrpclib.ServerProxy(url, _TimeoutTransport())
else:
socket.setdefaulttimeout(_REGISTER_TIMEOUT)
server = xmlrpclib.ServerProxy(url)
try:
data = server.register(sn, nick, uuid_, profile.pubkey)
except (xmlrpclib.Error, TypeError, socket.error):
logging.exception('Registration: cannot connect to server')
raise RegisterError(_('Cannot connect to the server.'))
finally:
socket.setdefaulttimeout(None)
if data['success'] != 'OK':
logging.error('Registration: server could not complete request: %s',
data['error'])
raise RegisterError(_('The server could not complete the request.'))
settings.set_string('jabber-server', data['jabberserver'])
settings = Gio.Settings('org.sugarlabs')
settings.set_string('backup-url', data['backupurl'])
# DEPRECATED
from gi.repository import GConf
client = GConf.Client.get_default()
client.set_string(
'/desktop/sugar/collaboration/jabber_server', data['jabberserver'])
client.set_string('/desktop/sugar/backup_url', data['backupurl'])
return True
开发者ID:AbrahmAB,项目名称:sugar,代码行数:55,代码来源:schoolserver.py
示例15: _do_finish
def _do_finish(self):
self._tarfile.close()
# Add metadata to the file created
metadata = model.get(self._checkpoint)
metadata['description'] = _('Backup from user %s') % \
profile.get_nick_name()
metadata['icon_color'] = profile.get_color().to_string()
metadata['uncompressed_size'] = self._uncompressed_size
metadata['mime_type'] = 'application/vnd.olpc-journal-backup'
model.write(metadata, self._checkpoint)
self.emit('finished')
开发者ID:curiousguy13,项目名称:sugar,代码行数:11,代码来源:volume.py
示例16: do_GET
def do_GET(self):
logging.error('do_GET path: %s', self.path)
student_data = parse_qs(urlparse(self.path).query)
GObject.idle_add(self._received_data_cb, student_data)
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
# Send the html message
teacher_data = {'nick_name': profile.get_nick_name()}
self.wfile.write(json.dumps(teacher_data))
return
开发者ID:godiard,项目名称:classroomexplore,代码行数:12,代码来源:activity.py
示例17: _service_resolved
def _service_resolved(self, *args):
logging.error('service resolved name: %s address %s port %s more %s',
args[2], args[7], args[8], args)
nick_name = profile.get_nick_name()
teacher_ip = args[7]
teacher_port = args[8]
teacher_xo_id = args[5]
for widget in self._vbox.get_children():
self._vbox.remove(widget)
label = Gtk.Label()
self._vbox.add(label)
text = ("My name is %s \n" % nick_name)
label.set_text(text)
label = Gtk.Label()
self._vbox.add(label)
text = ("Teacher ip: %s \n" % teacher_ip)
label.set_text(text)
label = Gtk.Label()
self._vbox.add(label)
text = ("Teacher port: %s \n" % teacher_port)
label.set_text(text)
label = Gtk.Label()
self._vbox.add(label)
text = ("Teacher xo id: %s \n" % teacher_xo_id)
label.set_text(text)
self._vbox.show_all()
# sent my information to the teacher
student_data = {}
student_data['nick_name'] = nick_name
student_data['age'] = self._age
student_data['gender'] = self._gender
url_values = urllib.urlencode(student_data)
response = urllib2.urlopen(
'http://%s:%d/student_info?%s' % (teacher_ip, teacher_port,
url_values))
json_data = response.read()
teacher_data = json.loads(json_data)
label = Gtk.Label()
self._vbox.add(label)
text = ("Teacher name: %s \n" % teacher_data['nick_name'])
label.set_text(text)
label.show()
开发者ID:godiard,项目名称:classroomexplore,代码行数:52,代码来源:activity.py
示例18: _add_link
def _add_link(self):
''' take screenshot and add link info to the model '''
browser = self._tabbed_view.props.current_browser
ui_uri = browser.get_uri()
for link in self.model.data['shared_links']:
if link['hash'] == sha1(ui_uri).hexdigest():
_logger.debug('_add_link: link exist already a=%s b=%s',
link['hash'], sha1(ui_uri).hexdigest())
return
buf = self._get_screenshot()
timestamp = time.time()
self.model.add_link(ui_uri, browser.props.title, buf,
profile.get_nick_name(),
profile.get_color().to_string(), timestamp)
if self.messenger is not None:
self.messenger._add_link(ui_uri, browser.props.title,
profile.get_color().to_string(),
profile.get_nick_name(),
base64.b64encode(buf), timestamp)
开发者ID:City-busz,项目名称:browse-activity,代码行数:22,代码来源:webactivity.py
示例19: get_user_data
def get_user_data():
"""
Create this structure:
{"from": "Walter Bender", "icon": ["#FFC169", "#FF2B34"]}
used to identify the owner of a shared object
is compatible with how the comments are saved in
http://wiki.sugarlabs.org/go/Features/Comment_box_in_journal_detail_view
"""
xo_color = profile.get_color()
data = {}
data['from'] = profile.get_nick_name()
data['icon'] = [xo_color.get_stroke_color(), xo_color.get_fill_color()]
return data
开发者ID:cristian99garcia,项目名称:teachershare,代码行数:13,代码来源:account.py
示例20: load_brain
def load_brain():
global _kernel
global _kernel_voice
is_first_session = _kernel is None
try:
if voice.friendlyname in BOTS:
brain = BOTS[voice.friendlyname]
brain_name = BOTS[voice.friendlyname]['name']
else:
brain = BOTS[_('English')]
brain_name = BOTS[_('English')]['name']
logger.debug('Load bot: %s' % brain)
kernel = aiml.Kernel()
if brain['brain'] is None:
warning = _("Sorry, there is no free memory to load my " \
"brain. Close other activities and try once more.")
activity.face.say_notification(warning)
return
kernel.loadBrain(brain['brain'])
for name, value in brain['predicates'].items():
kernel.setBotPredicate(name, value)
if _kernel is not None:
del _kernel
_kernel = None
import gc
gc.collect()
_kernel = kernel
_kernel_voice = voice
finally:
activity.get_window().set_cursor(old_cursor)
if is_first_session:
_kernel.respond(_('my name is %s') % (profile.get_nick_name()))
_kernel.respond(_('I am %d years old') % (_get_age()))
hello = \
_("Hello, I'm a robot \"%s\". Please ask me any question.") \
% brain_name
if sorry:
hello += ' ' + sorry
activity.face.say_notification(hello)
elif sorry:
activity.face.say_notification(sorry)
开发者ID:leonardcj,项目名称:speak,代码行数:49,代码来源:brain.py
注:本文中的sugar3.profile.get_nick_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论