示例#1
0
	def startAuthenticationProcess(self):
		self.settingsDialog.group_account.widget_authorize.button_authenticate.setEnabled(False)
		self.flow = dropbox.oauth.DropboxOAuth2FlowNoRedirect('sfacmqvdb9dn66r', 'hx8meda636xgsox')
		authorize_url = QUrl(self.flow.start())
		QDesktopServices.openUrl(authorize_url)
		try:
			code = raw_input("Enter the authorization code from the dropbox website:")
		except NameError:
			code = input("Enter the authorization code from the dropbox website:")
		if code:
			try:
				oauth2_result = self.flow.finish(code)
				self.access_token = oauth2_result.access_token
				self.client = dropbox.Dropbox(self.access_token)
				account = self.client.users_get_current_account()
				self.user_id = account.account_id
				self.display_name = account.name.display_name
			except dropbox.auth.AccessError:
				if "win" in sys.platform: #Workaround for crash on windows
					self.parentWidget.hide()
					self.settingsDialog.hide()
				QMessageBox.critical(self.settingsDialog, "Failed to authenticate", "Failed to authenticate with Dropbox. Wrong code?")
				if "win" in sys.platform:
					self.settingsDialog.show()
					self.parentWidget.show()
		self.saveSettings()
		self.updateUi()
示例#2
0
    def startAuthenticationProcess(self):
        self.settingsDialog.group_account.widget_authorize.button_authenticate.setEnabled(
            False)
        authorize_url = QUrl(
            self.client.auth_provider.get_auth_url(REDIRECT_URI))
        QDesktopServices.openUrl(authorize_url)
        try:
            code = raw_input(
                "Copy everything in the address bar after \"code=\", and paste it below:"
            )
        except NameError:
            code = input(
                "Copy everything in the address bar after \"code=\", and paste it below:"
            )
        if code:
            try:
                self.client.auth_provider.authenticate(code, REDIRECT_URI,
                                                       None)
            except:
                if "win" in sys.platform:  #Workaround for crash on windows
                    self.parentWidget.hide()
                    self.settingsDialog.hide()
                QMessageBox.critical(
                    self.settingsDialog, "Failed to authenticate",
                    "Failed to authenticate with OneDrive. Wrong code?")
                if "win" in sys.platform:
                    self.settingsDialog.show()
                    self.parentWidget.show()

        #Set display name
        self.displayName = self.client.drive.get().owner.user.display_name
        self.loggedIn = True

        self.saveSettings()
        self.updateUi()
示例#3
0
 def startAuthenticationProcess(self):
     self.settingsDialog.group_account.widget_authorize.button_authenticate.setEnabled(
         False)
     self.flow = dropbox.client.DropboxOAuth2FlowNoRedirect(
         'sfacmqvdb9dn66r', 'hx8meda636xgsox')
     authorize_url = QUrl(self.flow.start())
     QDesktopServices.openUrl(authorize_url)
     code = raw_input(
         "Enter the authorization code from the dropbox website:")
     if code:
         try:
             self.access_token, self.user_id = self.flow.finish(code)
             self.client = dropbox.client.DropboxClient(self.access_token)
             self.display_name = self.client.account_info()['display_name']
         except dropbox.rest.ErrorResponse:
             if "win" in sys.platform:  #Workaround for crash on windows
                 self.parentWidget.hide()
                 self.settingsDialog.hide()
             QMessageBox.critical(
                 self.settingsDialog, "Failed to authenticate",
                 "Failed to authenticate with Dropbox. Wrong code?")
             if "win" in sys.platform:
                 self.settingsDialog.show()
                 self.parentWidget.show()
     self.saveSettings()
     self.updateUi()
示例#4
0
 def SearchFinished():
   data = json.loads(str(reply.readAll()))
   feed = data['feed']
   try:
     print feed['entry'][0]['media$group']['media$player'][0]['url']
     youtube_url = feed['entry'][0]['media$group']['media$player'][0]['url']
     QDesktopServices.openUrl(QUrl.fromEncoded(str(youtube_url)))
   except Exception, e:
     print e
示例#5
0
 def SearchFinished():
     data = json.loads(str(reply.readAll()))
     feed = data["feed"]
     try:
         print feed["entry"][0]["media$group"]["media$player"][0]["url"]
         youtube_url = feed["entry"][0]["media$group"]["media$player"][0]["url"]
         QDesktopServices.openUrl(QUrl.fromEncoded(str(youtube_url)))
     except Exception, e:
         print e
示例#6
0
	def startAuthenticationProcess(self):
		self.saveSettings()
		self.loadSettings()
		self.settingsDialog.group_account.button_authenticate.setEnabled(False)
		self.settingsDialog.group_account.label_code.setEnabled(True)
		self.settingsDialog.group_account.input_code.setEnabled(True)
		self.settingsDialog.group_account.button_code.setEnabled(True)
		auth_url = self.imgur.authorization_url('pin')
		QDesktopServices.openUrl(QUrl(auth_url))
		self.settingsDialog.group_account.button_code.connect("clicked()", self.pinEntered)
示例#7
0
 def startAuthenticationProcess(self):
     self.settingsDialog.group_account.widget_authenticate.button_authenticate.setEnabled(False)
     self.settingsDialog.group_account.widget_authenticate.label_code.setEnabled(True)
     self.settingsDialog.group_account.widget_authenticate.input_code.setEnabled(True)
     self.settingsDialog.group_account.widget_authenticate.button_code.setEnabled(True)
     self.flow = dropbox.client.DropboxOAuth2FlowNoRedirect("sfacmqvdb9dn66r", "hx8meda636xgsox")
     authorize_url = QUrl(self.flow.start())
     QDesktopServices.openUrl(authorize_url)
     self.settingsDialog.group_account.widget_authenticate.button_code.connect(
         "clicked()", self.authorizationCodeEntered
     )
示例#8
0
 def updateReply(self, reply):
     version = loads(reply.readAll().data().decode('utf-8'))["version"]
     if version != self.version:
         x = QDialog()
         x.setAttribute(Qt.WA_DeleteOnClose)
         _x = QMessageBox.question(
             x, "{} v{} by {}".format(self.name, self.version, self.author),
             "Noua versiune v{} la linksteam a fost gasita, dai update acum?"
             .format(version), QMessageBox.Yes, QMessageBox.No)
         if _x == QMessageBox.Yes:
             QDesktopServices.openUrl(QUrl(self.repourl))
示例#9
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     try:
         url = ""
         if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT:
             if menuItemID == 1:  # Nickname (TSViewer)
                 url = "http://www.tsviewer.com/index.php?page=search&action=ausgabe_user&nickname=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 2:  # Nickname (GameTracker)
                 url = "http://www.gametracker.com/search/?search_by=online_offline_player&query=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 3:  # Nickname (TS3Index)
                 url = "http://ts3index.com/?page=searchclient&nickname=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 4:  # Nickname (Google)
                 url = "https://www.google.com/search?q=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 5:  # Profil (GameTracker)
                 url = "http://www.gametracker.com/search/?search_by=profile_username&query=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 6:  # UID (TS3Index)
                 url = "http://ts3index.com/?page=searchclient&uid=%%CLIENT_UNIQUE_ID%%"
             elif menuItemID == 7:  # UID (Google)
                 url = "https://www.google.com/search?q=%%CLIENT_UNIQUE_ID%%"
             elif menuItemID == 8:  # Besitzer (TSViewer)
                 url = "http://www.tsviewer.com/index.php?page=search&action=ausgabe&suchbereich=ansprechpartner&suchinhalt=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 9:  # Badges (TS3Index)
                 url = "https://ts3index.com/?page=searchclient&badges=%%CLIENT_BADGES%%"
             else:
                 return
             # payload = {'username':'******', 'password':'******'}
             # nickname_encoded = urlencode(nickname, quote_via=quote_plus)
             # nickname_encoded = nickname_encoded.replace("+", "%2B").replace("/", "%2F").replace("=", "%3D")
             if "%%CLIENT_NAME_PERCENT_ENCODED%%" in url:
                 (err, nickname) = ts3lib.getClientVariable(
                     schid, selectedItemID,
                     ts3defines.ClientProperties.CLIENT_NICKNAME)
                 url = url.replace("%%CLIENT_NAME_PERCENT_ENCODED%%",
                                   quote_plus(nickname))
             if "%%CLIENT_UNIQUE_ID%%" in url:
                 (err, uid) = ts3lib.getClientVariable(
                     schid, selectedItemID,
                     ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
                 url = url.replace("%%CLIENT_UNIQUE_ID%%", quote_plus(uid))
             if "%%CLIENT_BADGES%%" in url:
                 (err, badges) = ts3lib.getClientVariable(
                     schid, selectedItemID,
                     ts3defines.ClientPropertiesRare.CLIENT_BADGES)
                 url = url.replace("%%CLIENT_BADGES%%", badges)
         else:
             return
         if PluginHost.cfg.getboolean("general", "verbose"):
             ts3lib.printMessageToCurrentTab(
                 "Opening URL: \"{}\"".format(url))
         QDesktopServices.openUrl(QUrl(url))
     except:
         ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                           "pyTSon", 0)
示例#10
0
 def __init__(self):
     if isfile(self.bin):
         self.yatqa = QProcess()
         self.yatqa.setProgram(self.bin)
     else:
         msgBox(
             "Cannot find YatQA!\nPlease make sure it's installed at\n\n\"{}\""
             .format(self.bin))
         QDesktopServices.openUrl(QUrl("http://yat.qa/"))
     if PluginHost.cfg.getboolean("general", "verbose"):
         ts3lib.printMessageToCurrentTab(
             "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded."
             .format(timestamp(), self.name, self.author))
示例#11
0
	def startAuthenticationProcess(self):
		self.saveSettings()
		self.loadSettings()
		auth_url = self.imgur.authorization_url('pin')
		QDesktopServices.openUrl(QUrl(auth_url))
		pin = raw_input("Enter PIN from imgur website:")
		if pin:
			try:
				self.access_token, self.refresh_token = self.imgur.exchange_pin(pin)
			except KeyError as e:
				QMessageBox.critical(self.settingsDialog, "Imgur key error", "Failed to exchange pin. " + e.message)
		self.access_token, self.username = self.imgur.refresh_access_token()
		self.saveSettings()
		self.updateUi()
示例#12
0
    def upload(self, screenshot, name):
        self.loadSettings()
        if self.loggedIn:
            self.client.auth_provider.refresh_token()
        #Save to 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())
        #Workaround to get id of app folder
        import requests, json
        endpoint = "https://api.onedrive.com/v1.0/drives/me/special/approot"
        headers = {
            "Authorization": "Bearer " + self.client.auth_provider.access_token
        }
        response = requests.get(endpoint, headers=headers).json()
        appfolder_id = response["id"]
        #Upload
        uploaded_item = self.client.item(drive='me', id=appfolder_id).children[
            ScreenCloud.formatFilename(name)].upload(tmpFilename)
        print(uploaded_item, " ".join(dir(uploaded_item)), str(uploaded_item),
              uploaded_item.id, uploaded_item.image)
        if self.copyLink:
            permission = self.client.item(
                id=uploaded_item.id).create_link("view").post()
            ScreenCloud.setUrl(permission.link.web_url)

        return True
示例#13
0
	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
示例#14
0
 def browseForKeyfile(self):
     filename = QFileDialog.getOpenFileName(
         self.settingsDialog, "Select Keyfile...",
         QDesktopServices.storageLocation(QDesktopServices.HomeLocation),
         "*")
     if filename:
         self.settingsDialog.group_server.input_keyfile.setText(filename)
示例#15
0
    def upload(self, screenshot, name):
        self.loadSettings()
        tmpFilename = QDesktopServices.storageLocation(
            QDesktopServices.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
示例#16
0
 def startAuthenticationProcess(self):
     self.saveSettings()
     self.loadSettings()
     auth_url = self.imgur.authorization_url('pin')
     QDesktopServices.openUrl(QUrl(auth_url))
     pin = raw_input("Enter PIN from imgur website:")
     if pin:
         try:
             self.access_token, self.refresh_token = self.imgur.exchange_pin(
                 pin)
         except KeyError as e:
             QMessageBox.critical(self.settingsDialog, "Imgur key error",
                                  "Failed to exchange pin. " + e.message)
     self.access_token, self.username = self.imgur.refresh_access_token()
     self.saveSettings()
     self.updateUi()
示例#17
0
	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
示例#18
0
	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
示例#19
0
 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
示例#20
0
	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())

		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
示例#21
0
	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
示例#22
0
    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
示例#23
0
def getPluginDir():
    try:
        return QDesktopServices.storageLocation(
            QDesktopServices.DataLocation) + "/plugins"
    except AttributeError:
        from PythonQt.QtCore import QStandardPaths
        return QStandardPaths.writableLocation(
            QStandardPaths.DataLocation) + "/plugins"
示例#24
0
 def browseForKeyfile(self):
     filename = QFileDialog.getOpenFileName(
         self.settingsDialog,
         "Select Keyfile...",
         QDesktopServices.storageLocation(QDesktopServices.HomeLocation),
         "*",
     )
     if filename:
         self.settingsDialog.group_server.input_keyfile.setText(filename)
示例#25
0
    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
示例#26
0
	def __init__(self):
		try:
			tempLocation = QDesktopServices.storageLocation(QDesktopServices.TempLocation)
		except AttributeError:
			from PythonQt.QtCore import QStandardPaths #fix for Qt5
			tempLocation = QStandardPaths.writableLocation(QStandardPaths.TempLocation)

		self.uil = QUiLoader()
		self.loadSettings()
示例#27
0
	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()
示例#28
0
 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
示例#29
0
	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()
示例#30
0
    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()
示例#31
0
 def startAuthenticationProcess(self):
     self.settingsDialog.group_account.widget_authorize.button_authenticate.setEnabled(
         False)
     self.flow = client.OAuth2WebServerFlow(
         client_id=self.clientID,
         client_secret=self.clientSecret,
         scope=SCOPES,
         redirect_uri="urn:ietf:wg:oauth:2.0:oob")
     authorize_url = QUrl(self.flow.step1_get_authorize_url())
     QDesktopServices.openUrl(authorize_url)
     try:
         code = raw_input(
             "Enter the authorization code from the Google Drive website:")
     except NameError:
         code = input(
             "Enter the authorization code from the Google Drive website:")
     if code:
         try:
             oauth2_result = self.flow.step2_exchange(code)
             self.accessToken = oauth2_result.access_token
             self.refreshToken = oauth2_result.refresh_token
             self.driveService = build('drive',
                                       'v3',
                                       http=oauth2_result.authorize(Http()))
             account = self.driveService.about().get(
                 fields="user").execute()
             self.displayName = account["user"]["displayName"]
         except client.Error:
             if "win" in sys.platform:  #Workaround for crash on windows
                 self.parentWidget.hide()
                 self.settingsDialog.hide()
             QMessageBox.critical(
                 self.settingsDialog, "Failed to authenticate",
                 "Failed to authenticate with Google Drive. Wrong code?")
             if "win" in sys.platform:
                 self.settingsDialog.show()
                 self.parentWidget.show()
     self.saveSettings()
     self.updateUi()
示例#32
0
	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
    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
示例#34
0
    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
示例#35
0
    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
示例#36
0
    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 = nextcloud.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 NextCloud. " + e.message)
            return False
示例#37
0
 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
示例#38
0
    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
示例#39
0
	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
示例#40
0
	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
示例#41
0
    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:
            if self.outputIsUrl:
                pipe = subprocess.PIPE
            else:
                pipe = None

            p = subprocess.Popen(command, shell=True, stdout=pipe)
            p.wait()
            if p.returncode > 0:
                ScreenCloud.setError(
                    "Command %s returned %d, but 0 was expected" %
                    (str(command), int(p.returncode)))
                return False
            elif self.outputIsUrl:
                result = bytes.decode(p.stdout.read())
                result = result.strip()
                ScreenCloud.setUrl(result)

        except OSError:
            ScreenCloud.setError("Failed to run command " + command)
            return False

        return True
示例#42
0
    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
示例#43
0
    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())
        base_path = os.path.dirname(os.path.realpath(__file__)) + '/'
        command = "bash " + base_path + "puush.sh " + self.apiKey + " " + tmpFilename
        try:
            command = command.encode(sys.getfilesystemencoding())
        except UnicodeEncodeError:
            ScreenCloud.setError("Invalid characters in command '" + command +
                                 "'")
            return False
        try:
            if self.outputIsUrl:
                pipe = subprocess.PIPE
            else:
                pipe = None

            p = subprocess.Popen(command, shell=True, stdout=pipe)
            p.wait()
            if p.returncode > 0:
                ScreenCloud.setError("Command " + command +
                                     " did not return 0")
                return False
            elif self.outputIsUrl:
                result = p.stdout.read()
                result = result.strip()
                ScreenCloud.setUrl(result)

        except OSError:
            ScreenCloud.setError("Failed to run command " + command)
            return False

        return True
示例#44
0
	def upload(self, screenshot, name):
		self.loadSettings()
		url = self.url_address

		if not url.startswith('http'):
			ScreenCloud.setError('Invalid url!')
			return False

		timestamp = time.time()
		tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
		screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())

		reply = requests.post(url,
							  files={'image': open(tmpFilename, 'rb')}
							  ).json()

		try:
			ScreenCloud.setUrl(reply['href'])
		except Exception as e:
			ScreenCloud.setError("Could not upload to: " + self.url_address + "\nError: " + e.message)
			return False
		return True
示例#45
0
	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:
			if self.outputIsUrl:
				pipe = subprocess.PIPE
			else:
				pipe = None


			p = subprocess.Popen(command, shell=True, stdout=pipe)
			p.wait()
			if p.returncode > 0:
				ScreenCloud.setError("Command %s returned %d, but 0 was expected" % (str(command), int(p.returncode)))
				return False
			elif self.outputIsUrl:
				result = bytes.decode(p.stdout.read())
				result = result.strip()
				ScreenCloud.setUrl(result)

		except OSError:
			ScreenCloud.setError("Failed to run command " + command)
			return False

		return True
示例#46
0
 def on_downloaddirButton_clicked(self):
     QDesktopServices.openUrl(QUrl(self.downloaddir))
示例#47
0
def getPluginDir():
	return QDesktopServices.storageLocation(QDesktopServices.DataLocation) + "/plugins"
示例#48
0
	def __init__(self):
		paramiko.util.log_to_file(QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/screencloud-sftp.log")
		self.uil = QUiLoader()
		self.loadSettings()
示例#49
0
 def __init__(self):
     paramiko.util.log_to_file(
         QDesktopServices.storageLocation(QDesktopServices.TempLocation) +
         "/screencloud-sftp.log")
     self.uil = QUiLoader()
     self.loadSettings()
示例#50
0
 def on_downloaddirButton_clicked(self):
     QDesktopServices.openUrl(QUrl(self.downloaddir))
 def Homepage(self):
   QDesktopServices.openUrl(self.HOMEPAGE_URL)
示例#52
0
	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:
			sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
			sock.connect((self.host, self.port))
			session = Session()
			session.handshake(sock)
		except Exception as e:
			ScreenCloud.setError(e.message)
			return False
		if self.authMethod == "Password":
			try:
				session.userauth_password(self.username, self.password)
			except ssh2.exceptions.AuthenticationError:
				ScreenCloud.setError("Authentication failed (password)")
				return False
		else:
			try:
				session.userauth_publickey_fromfile(self.username, self.keyfile, passphrase=self.passphrase)
			except ssh2.exceptions.AuthenticationError:
				ScreenCloud.setError("Authentication failed (key)")
				return False
			except Exception as e:
				ScreenCloud.setError("Unknown error: " + e.message)
				return False
		sftp = session.sftp_init()
		mode = LIBSSH2_SFTP_S_IRUSR | \
			LIBSSH2_SFTP_S_IWUSR | \
			LIBSSH2_SFTP_S_IRGRP | \
			LIBSSH2_SFTP_S_IROTH
		f_flags = LIBSSH2_FXF_CREAT | LIBSSH2_FXF_WRITE
		try:
			try:
				sftp.opendir(self.folder)
			except ssh2.exceptions.SFTPError:
				sftp.mkdir(self.folder, mode | LIBSSH2_SFTP_S_IXUSR)
			(filepath, filename) = os.path.split(ScreenCloud.formatFilename(name))
			if len(filepath):
				for folder in filepath.split("/"):
					try:
						sftp.mkdir(folder)
					except IOError:
						pass
			source = tmpFilename
			destination = self.folder + "/" + ScreenCloud.formatFilename(filename)
			with open(source, 'rb') as local_fh, sftp.open(destination, f_flags, mode) as remote_fh:
				for data in local_fh:
					remote_fh.write(data)
		except IOError:
			ScreenCloud.setError("Failed to write " + self.folder + "/" + ScreenCloud.formatFilename(name) + ". Check permissions.")
			return False
		sock.close()
		if self.url:
			ScreenCloud.setUrl(self.url + ScreenCloud.formatFilename(name))
		return True
示例#53
0
def getPluginDir():
    return QDesktopServices.storageLocation(
        QDesktopServices.DataLocation) + "/plugins"
示例#54
0
def getPluginDir():
	try:
		return QDesktopServices.storageLocation(QDesktopServices.DataLocation) + "/plugins"
	except AttributeError:
		from PythonQt.QtCore import QStandardPaths
		return QStandardPaths.writableLocation(QStandardPaths.DataLocation) + "/plugins"
示例#55
0
文件: main.py 项目: kacpersaw/yascp
	def upload(self, screenshot, name):
		self.loadSettings()
		f = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(name)
		screenshot.save(QFile(f), ScreenCloud.getScreenshotFormat())

		now = datetime.datetime.now()
		date = "/%s/%02d/%02d" % (now.year, now.month, now.day)
		path = "/%s/%02d/%02d/%s" % (now.year, now.month, now.day, ScreenCloud.formatFilename(name))

		if self.type == "SFTP":
			transport = paramiko.Transport((self.host, self.port))
			transport.connect(username = self.username, password = self.password)

			sftp = paramiko.SFTPClient.from_transport(transport)
			try:
				sftp.chdir(os.path.normpath(self.path) + date)
			except IOError:
				sftp.mkdir(os.path.normpath(self.path) + date)

			try:
				sftp.put(f, os.path.normpath(self.path) + path)
			except IOError:
				ScreenCloud.setError("Failed to write file")
			
			sftp.close()
			transport.close()
		elif self.type == "FTP":
			ftp = ftplib.FTP()
			ftp.connect(self.host, self.port)
			ftp.login(self.username, self.password)
			
			if os.path.normpath(self.path) in ftp.nlst():
				try:
					ftp.cwd(os.path.normpath(self.path))
				except ftplib.error_perm as err:
					ScreenCloud.setError(err.message)
					return False

			year = "%02d" % now.year
			month = "%02d" % now.month
			day = "%02d" % now.day

			if year in ftp.nlst():
				ftp.cwd(year)
			else:
				ftp.mkd(year)
				ftp.cwd(year)

			if month in ftp.nlst():
				ftp.cwd(month)
			else:
				ftp.mkd(month)
				ftp.cwd(month)

			if day in ftp.nlst():
				ftp.cwd(day)
			else:
				ftp.mkd(day)
				ftp.cwd(day)

			#borrowed from screencloud ftp plugin
			fs = open(f, 'rb')
			try:
				ftp.storbinary('STOR ' + name, fs)
			except ftplib.error_perm as err:
				ScreenCloud.setError(err.message)
				return False

			ftp.quit()
			fs.close()

		url = "%s%s/%s/%s/%s" % (self.url, now.year, now.month, now.day, ScreenCloud.formatFilename(name))
		ScreenCloud.setUrl(self.url.strip("/") + path)

		return True