当前位置: 首页>>代码示例>>Python>>正文


Python ScreenCloud类代码示例

本文整理汇总了Python中ScreenCloud的典型用法代码示例。如果您正苦于以下问题:Python ScreenCloud类的具体用法?Python ScreenCloud怎么用?Python ScreenCloud使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ScreenCloud类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upload

	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
开发者ID:SpiderX,项目名称:screencloud-plugins,代码行数:29,代码来源:main.py

示例2: upload

	def upload(self, screenshot, name):
		self.loadSettings()
		f = QFile(self.folder + "/" + ScreenCloud.formatFilename(name))
		f.open(QIODevice.WriteOnly)
		if not f.isWritable():
			ScreenCloud.setError("File " + f.fileName() + " is not writable!")
			return False
		screenshot.save(f, ScreenCloud.getScreenshotFormat())
		f.close()
		return True
开发者ID:Ichbinjoe,项目名称:screencloud-plugins,代码行数:10,代码来源:main.py

示例3: upload

	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
开发者ID:Rocik,项目名称:screencloud-plugins,代码行数:26,代码来源:main.py

示例4: upload

	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
开发者ID:SilverCory,项目名称:screencloud-plugins,代码行数:15,代码来源:main.py

示例5: upload

    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
开发者ID:gvsurenderreddy,项目名称:noelshack-screencloud,代码行数:16,代码来源:main.py

示例6: upload

    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
开发者ID:seanc,项目名称:screencloud-vgy,代码行数:16,代码来源:main.py

示例7: upload

 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
开发者ID:SkyzohKey,项目名称:ScreenCloud-Uguu,代码行数:17,代码来源:main.py

示例8: upload

	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
开发者ID:SpiderX,项目名称:screencloud-plugins,代码行数:26,代码来源:main.py

示例9: upload

    def upload(self, screenshot, name):
        q_byte_array = QByteArray()
        q_buffer = QBuffer(q_byte_array)
        q_buffer.open(QIODevice.WriteOnly)
        screenshot.save(q_buffer, ScreenCloud.getScreenshotFormat()) # writes image to byte array
        q_buffer.close()

        json_data = json.dumps({'image': str(q_byte_array.toBase64())})
        #f = open('/tmp/zapier', 'w')
        #f.write("{}\n{}\n\n".format(self.zapier_url, json_data))
        #f.close()
        response = requests.post(url=self.zapier_url,
                                 data=json_data,
                                 headers={'Content-Type': 'application/json'})

        try:
            response.raise_for_status()
        except Exception as e:
            ScreenCloud.setError("Could not upload to: " + self.zapier_url + "\n" + e.message)
            return False

        try:
            ScreenCloud.setUrl(response.json()['link'])
        except Exception as e:
            ScreenCloud.setError("Upload to {} worked, but response was invalid: {}\n{}".format(self.zapier_url, response.content, e.message))
            return False

        return True
开发者ID:bcooksey,项目名称:zapier-screencloud,代码行数:28,代码来源:main.py

示例10: upload

	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
开发者ID:olav-st,项目名称:screencloud-plugins,代码行数:19,代码来源:main.py

示例11: upload

	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
开发者ID:teryanik,项目名称:screencloud-plugins,代码行数:19,代码来源:main.py

示例12: upload

	def upload(self, screenshot, name):
		ba = QByteArray()
		buf = QBuffer(ba)
		buf.open(QIODevice.WriteOnly)
		screenshot.save( buf, ScreenCloud.getScreenshotFormat() ) #writes image into ba
		buf.close()

		json_data = json.dumps({'image': ba.toBase64().data()})
		request = urllib2.Request(self.zapier_url, json_data, {"Content-Type": "application/json"})
		try:
			reply = urllib2.urlopen(request)
		except Exception as e:
			ScreenCloud.setError("Could not upload to: "+ self.zapier_url + "\n" + e.message)
			return False
		try:
			replyText = reply.read()
			ScreenCloud.setUrl(json.loads(replyText).link)
		except Exception as e:
			ScreenCloud.setError("Could not upload to: "+ self.zapier_url + "\n" + e.message)
			return False
		return True
开发者ID:olav-st,项目名称:zapier-screencloud,代码行数:21,代码来源:main.py

示例13: upload

    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
开发者ID:monokles,项目名称:screencloud-owncloud-shoxy,代码行数:40,代码来源:main.py

示例14: getFilename

	def getFilename(self):
		timestamp = time.time()
		return ScreenCloud.formatFilename(str(timestamp))
开发者ID:olav-st,项目名称:screencloud-plugins,代码行数:3,代码来源:main.py

示例15: nameFormatEdited

 def nameFormatEdited(self, nameFormat):
     self.settingsDialog.group_name.label_example.setText(ScreenCloud.formatFilename(nameFormat, False))
开发者ID:RobKellett,项目名称:ScreenCloud-Uguu,代码行数:2,代码来源:main.py


注:本文中的ScreenCloud类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。