本文整理汇总了Python中PythonQt.QtGui.QDesktopServices.storageLocation方法的典型用法代码示例。如果您正苦于以下问题:Python QDesktopServices.storageLocation方法的具体用法?Python QDesktopServices.storageLocation怎么用?Python QDesktopServices.storageLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonQt.QtGui.QDesktopServices
的用法示例。
在下文中一共展示了QDesktopServices.storageLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
self.loadSettings()
#Make sure we have a up to date token
if not self.uploadAnon:
try:
self.imgur.refresh_access_token()
except Exception as e:
ScreenCloud.setError("Failed to refresh imgur access token. " + e.message)
return False
#Save to a temporary file
timestamp = time.time()
try:
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
except AttributeError:
from PythonQt.QtCore import QStandardPaths #fix for Qt5
tmpFilename = QStandardPaths.writableLocation(QStandardPaths.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
#Upload!
try:
uploaded_image = self.imgur.upload_image(tmpFilename, title=ScreenCloud.formatFilename(name, False))
except Exception as e:
ScreenCloud.setError("Failed to upload to imgur. " + e.message)
return False
if self.copyLink:
if self.copyDirectLink:
ScreenCloud.setUrl(uploaded_image.link)
else:
ScreenCloud.setUrl("https://imgur.com/" + uploaded_image.id)
return True
示例2: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
self.loadSettings()
#Save to a temporary file
timestamp = time.time()
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
#Connect to server
transport = paramiko.Transport((self.host, self.port))
if self.authMethod == "Password":
try:
transport.connect(username = self.username, password = self.password)
except paramiko.AuthenticationException:
ScreenCloud.setError("Authentication failed (password)")
return False
else:
try:
private_key = paramiko.RSAKey.from_private_key_file(self.keyfile, password=self.passphrase)
transport.connect(username=self.username, pkey=private_key)
except paramiko.AuthenticationException:
ScreenCloud.setError("Authentication failed (key)")
return False
sftp = paramiko.SFTPClient.from_transport(transport)
try:
sftp.put(tmpFilename, self.folder + "/" + ScreenCloud.formatFilename(name))
except IOError:
ScreenCloud.setError("Failed to write " + self.folder + "/" + ScreenCloud.formatFilename(name) + ". Check permissions.")
return False
sftp.close()
transport.close()
if self.url:
ScreenCloud.setUrl(self.url + ScreenCloud.formatFilename(name))
return True
示例3: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
self.loadSettings()
try:
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + name
except AttributeError:
from PythonQt.QtCore import QStandardPaths #fix for Qt5
tmpFilename = QStandardPaths.writableLocation(QStandardPaths.TempLocation) + "/" + name
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
command = string.Formatter().vformat(self.commandFormat, (), defaultdict(str, s = tmpFilename))
try:
command = command.encode(sys.getfilesystemencoding())
except UnicodeEncodeError:
ScreenCloud.setError("Invalid characters in command '" + command + "'")
return False
try:
p = subprocess.Popen(command.split())
p.wait()
if p.returncode > 0:
ScreenCloud.setError("Command " + command + " did not return 0")
return False
except OSError:
ScreenCloud.setError("Failed to run command " + command)
return False
return True
示例4: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
self.loadSettings()
timestamp = time.time()
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
ftp = ftplib.FTP()
ftp.connect(self.host, self.port)
ftp.login(self.username, self.password)
f = open(tmpFilename, 'rb')
try:
ftp.cwd(self.folder)
except ftplib.error_perm as err:
ScreenCloud.setError(err.message)
return False
try:
ftp.storbinary('STOR ' + name, f)
except ftplib.error_perm as err:
ScreenCloud.setError(err.message)
return False
ftp.quit()
f.close()
if self.url:
ScreenCloud.setUrl(self.url + ScreenCloud.formatFilename(name))
return True
示例5: __init__
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def __init__(self):
paramiko.util.log_to_file(QDesktopServices.storageLocation(QDesktopServices.HomeLocation) + "/screencloud-sftp.log")
uil = QUiLoader()
self.settingsDialog = uil.load(QFile(workingDir + "/settings.ui"))
self.settingsDialog.group_server.combo_auth.connect("currentIndexChanged(QString)", self.authMethodChanged)
self.settingsDialog.group_server.button_browse.connect("clicked()", self.browseForKeyfile)
self.settingsDialog.group_location.input_name.connect("textChanged(QString)", self.nameFormatEdited)
self.loadSettings()
self.updateUi()
示例6: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
self.loadSettings()
# Save to a temporary file
timestamp = time.time()
try:
tmpFilename = (
QDesktopServices.storageLocation(QDesktopServices.TempLocation)
+ "/"
+ ScreenCloud.formatFilename(str(timestamp))
)
except AttributeError:
from PythonQt.QtCore import QStandardPaths # fix for Qt5
tmpFilename = (
QStandardPaths.writableLocation(QStandardPaths.TempLocation)
+ "/"
+ ScreenCloud.formatFilename(str(timestamp))
)
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
# Connect to server
try:
transport = paramiko.Transport((self.host, self.port))
except Exception as e:
ScreenCloud.setError(e.message)
return False
if self.authMethod == "Password":
try:
transport.connect(username=self.username, password=self.password)
except paramiko.AuthenticationException:
ScreenCloud.setError("Authentication failed (password)")
return False
else:
try:
private_key = paramiko.RSAKey.from_private_key_file(self.keyfile, password=self.passphrase)
transport.connect(username=self.username, pkey=private_key)
except paramiko.AuthenticationException:
ScreenCloud.setError("Authentication failed (key)")
return False
except paramiko.SSHException as e:
ScreenCloud.setError("Error while connecting to " + self.host + ":" + str(self.port) + ". " + e.message)
return False
except Exception as e:
ScreenCloud.setError("Unknown error: " + e.message)
return False
sftp = paramiko.SFTPClient.from_transport(transport)
try:
sftp.put(tmpFilename, self.folder + "/" + ScreenCloud.formatFilename(name))
except IOError:
ScreenCloud.setError(
"Failed to write " + self.folder + "/" + ScreenCloud.formatFilename(name) + ". Check permissions."
)
return False
sftp.close()
transport.close()
if self.url:
ScreenCloud.setUrl(self.url + ScreenCloud.formatFilename(name))
return True
示例7: browseForKeyfile
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def browseForKeyfile(self):
filename = QFileDialog.getOpenFileName(
self.settingsDialog,
"Select Keyfile...",
QDesktopServices.storageLocation(QDesktopServices.HomeLocation),
"*",
)
if filename:
self.settingsDialog.group_server.input_keyfile.setText(filename)
示例8: __init__
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def __init__(self):
try:
tempLocation = QDesktopServices.storageLocation(QDesktopServices.TempLocation)
except AttributeError:
from PythonQt.QtCore import QStandardPaths #fix for Qt5
tempLocation = QStandardPaths.writableLocation(QStandardPaths.TempLocation)
paramiko.util.log_to_file(tempLocation + "/screencloud-sftp.log")
self.uil = QUiLoader()
self.loadSettings()
示例9: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
self.loadSettings()
timestamp = time.time()
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
f = open(tmpFilename, 'rb')
response = self.client.put_file('/' + ScreenCloud.formatFilename(name), f)
f.close()
os.remove(tmpFilename)
if self.copy_link:
share = self.client.share('/' + ScreenCloud.formatFilename(name))
ScreenCloud.setUrl(share['url'])
return True
示例10: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
temp = QDesktopServices.storageLocation(QDesktopServices.TempLocation)
file = temp + '/' + name
screenshot.save(QFile(file), ScreenCloud.getScreenshotFormat())
ns = NoelShack()
try:
url = ns.upload(file)
except NoelShackError as e:
ScreenCloud.setError(str(e))
return False
ScreenCloud.setUrl(url)
return True
示例11: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
temp = QDesktopServices.storageLocation(QDesktopServices.TempLocation)
file = temp + '/' + name
screenshot.save(QFile(file), ScreenCloud.getScreenshotFormat())
register_openers()
datagen, headers = multipart_encode({'file': open(file, 'rb')})
req = urllib2.Request('https://vgy.me:443/upload', datagen, headers)
res = json.loads(urllib2.urlopen(req).read())
ScreenCloud.setUrl(res['url'])
return True
示例12: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
self.loadSettings()
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(time.time()))
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
data = {"name": name}
files = {"file": open(tmpFilename, "rb")}
try:
response = requests.post("http://uguu.se/api.php?d=upload-tool", data=data, files=files)
response.raise_for_status()
if self.copyLink:
ScreenCloud.setUrl(response.text)
except RequestException as e:
ScreenCloud.setError("Failed to upload to Uguu.se: " + e.message)
return False
return True
示例13: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
self.loadSettings()
timestamp = time.time()
try:
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
except AttributeError:
from PythonQt.QtCore import QStandardPaths #fix for Qt5
tmpFilename = QStandardPaths.writableLocation(QStandardPaths.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
f = open(tmpFilename, 'rb')
response = self.client.put_file('/' + ScreenCloud.formatFilename(name), f)
f.close()
os.remove(tmpFilename)
if self.copy_link:
share = self.client.share('/' + ScreenCloud.formatFilename(name), False)
ScreenCloud.setUrl(share['url'].replace('dl=0', 'raw=1'))
return True
示例14: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
self.loadSettings()
timestamp = time.time()
try:
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
except AttributeError:
from PythonQt.QtCore import QStandardPaths #fix for Qt5
tmpFilename = QStandardPaths.writableLocation(QStandardPaths.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
f = open(tmpFilename, 'rb')
response = self.client.files_upload(f, '/' + ScreenCloud.formatFilename(name))
f.close()
os.remove(tmpFilename)
if self.copy_link:
share = self.client.sharing_create_shared_link('/' + ScreenCloud.formatFilename(name), short_url=True)
ScreenCloud.setUrl(share.url)
return True
示例15: upload
# 需要导入模块: from PythonQt.QtGui import QDesktopServices [as 别名]
# 或者: from PythonQt.QtGui.QDesktopServices import storageLocation [as 别名]
def upload(self, screenshot, name):
self.loadSettings()
timestamp = time.time()
try:
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
except AttributeError:
from PythonQt.QtCore import QStandardPaths #fix for Qt5
tmpFilename = QStandardPaths.writableLocation(QStandardPaths.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
try:
oc = owncloud.Client(self.url)
oc.login(self.username, self.password)
remotePath = ""
if self.remotePath:
remotePath = self.remotePath
try:
oc.file_info(remotePath)
except Exception:
oc.mkdir(remotePath)
uploaded_image = oc.put_file(remotePath + "/" + ScreenCloud.formatFilename(name, False), tmpFilename)
if self.copyLink:
link_info = oc.share_file_with_link(remotePath + "/" + ScreenCloud.formatFilename(name, False))
share_link = link_info.get_link()
if self.copyDirectLink:
share_link = share_link + "/download"
ScreenCloud.setUrl(share_link)
return True
except Exception as e:
ScreenCloud.setError("Failed to upload to OwnCloud. " + e.message)
return False