本文整理汇总了Python中common.file_props.FilesProp.getNewFileProp方法的典型用法代码示例。如果您正苦于以下问题:Python FilesProp.getNewFileProp方法的具体用法?Python FilesProp.getNewFileProp怎么用?Python FilesProp.getNewFileProp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.file_props.FilesProp
的用法示例。
在下文中一共展示了FilesProp.getNewFileProp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_yes
# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getNewFileProp [as 别名]
def on_yes(dummy, fjid, file_props, account):
# Delete old file
os.remove(file_props.file_name)
jid, resource = gajim.get_room_and_nick_from_fjid(fjid)
if resource:
contact = gajim.contacts.get_contact(account, jid, resource)
else:
contact = gajim.contacts.get_contact_with_highest_priority(
account, jid)
fjid = contact.get_full_jid()
# Request the file to the sender
sid = helpers.get_random_string_16()
new_file_props = FilesProp.getNewFileProp(account, sid)
new_file_props.file_name = file_props.file_name
new_file_props.name = file_props.name
new_file_props.desc = file_props.desc
new_file_props.size = file_props.size
new_file_props.date = file_props.date
new_file_props.hash_ = file_props.hash_
new_file_props.type_ = 'r'
tsid = gajim.connections[account].start_file_transfer(fjid,
new_file_props,
True)
new_file_props.transport_sid = tsid
self.add_transfer(account, contact, new_file_props)
示例2: get_send_file_props
# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getNewFileProp [as 别名]
def get_send_file_props(self, account, contact, file_path, file_name,
file_desc=''):
"""
Create new file_props object and set initial file transfer
properties in it
"""
if os.path.isfile(file_path):
stat = os.stat(file_path)
else:
dialogs.ErrorDialog(_('Invalid File'), _('File: ') + file_path)
return None
if stat[6] == 0:
dialogs.ErrorDialog(_('Invalid File'),
_('It is not possible to send empty files'))
return None
file_props = FilesProp.getNewFileProp(account,
sid=helpers.get_random_string_16())
mod_date = os.path.getmtime(file_path)
file_props.file_name = file_path
file_props.name = file_name
file_props.date = self.__convert_date(mod_date)
file_props.type_ = 's'
file_props.desc = file_desc
file_props.elapsed_time = 0
file_props.size = stat[6]
file_props.sender = account
file_props.receiver = contact
file_props.tt_account = account
return file_props
示例3: __init__
# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getNewFileProp [as 别名]
def __init__(self, host, port, jid, sid, sender_jid, on_success, on_failure):
"""
Try to establish and auth to proxy at (host, port)
Call on_success, or on_failure according to the result.
"""
self.host = host
self.port = port
self.jid = jid
self.on_success = on_success
self.on_failure = on_failure
self._sock = None
self.file_props = FilesProp.getNewFileProp(jid, sid)
self.file_props.is_a_proxy = True
self.file_props.proxy_sender = sender_jid
self.file_props.proxy_receiver = '[email protected]/test2'
Socks5.__init__(self, gajim.idlequeue, host, port, None, None, None)
self.sid = sid
示例4: on_download_clicked
# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getNewFileProp [as 别名]
def on_download_clicked(self, widget, data=None):
tree, row = self.tv_search.get_selection().get_selected()
path = tree.get_path(row)
file_info = self.brw_file_info[path]
fjid = self.get_contact_from_iter(tree, row)
# Request the file
file_path = os.path.join(self.plugin.config['incoming_dir'],
file_info[0])
sid = helpers.get_random_string_16()
new_file_props = FilesProp.getNewFileProp(self.account, sid)
new_file_props.file_name = file_path
print file_path
new_file_props.name = file_info[0]
new_file_props.desc = file_info[4]
new_file_props.size = file_info[2]
new_file_props.date = file_info[1]
new_file_props.hash_ = None if file_info[3] == '' else file_info[3]
new_file_props.type_ = 'r'
tsid = gajim.connections[self.account].start_file_transfer(fjid,
new_file_props, True)
new_file_props.transport_sid = tsid
ft_window = gajim.interface.instances['file_transfers']
contact = gajim.contacts.get_contact_from_full_jid(self.account, fjid)
ft_window .add_transfer(self.account, contact, new_file_props)