def setUp(self): credentials = Credentials( ) #Gets your Smartling credetnials from environment variables self.MY_USER_IDENTIFIER = credentials.MY_USER_IDENTIFIER self.MY_USER_SECRET = credentials.MY_USER_SECRET self.MY_PROJECT_ID = credentials.MY_PROJECT_ID self.MY_LOCALE = credentials.MY_LOCALE #needed for testProjects self.MY_ACCOUNT_UID = credentials.MY_ACCOUNT_UID useProxy = False if useProxy: proxySettings = ProxySettings("login", "password", "proxy_host", "proxy_port or None") else: proxySettings = None self.fapi = SmartlingFileApiV2(self.MY_USER_IDENTIFIER, self.MY_USER_SECRET, self.MY_PROJECT_ID, proxySettings) unique_suffix = "_" + version + "_" + ` time.time() ` self.uri = self.FILE_NAME + unique_suffix self.doUpload(self.FILE_NAME, self.uri, self.FILE_TYPE) self.uri_csv = self.FILE_NAME_CSV + unique_suffix self.uri16 = self.FILE_NAME_16 + unique_suffix self.doUpload(self.FILE_NAME_16, self.uri16, self.FILE_TYPE) self.uri_to_rename = self.FILE_NAME_NEW + unique_suffix self.uri_import = self.FILE_NAME_IMPORT_ORIG + unique_suffix print "setUp", "OK", "\n\n\n"
def __init__(self, file_name, file_type, new_name): credentials = Credentials( ) #Gets your Smartling credetnials from environment variables self.MY_USER_IDENTIFIER = credentials.MY_USER_IDENTIFIER self.MY_USER_SECRET = credentials.MY_USER_SECRET self.MY_PROJECT_ID = credentials.MY_PROJECT_ID self.MY_LOCALE = credentials.MY_LOCALE useProxy = False if useProxy: proxySettings = ProxySettings("login", "password", "proxy_host", "proxy_port") else: proxySettings = None self.fapi = SmartlingFileApiV2(self.MY_USER_IDENTIFIER, self.MY_USER_SECRET, self.MY_PROJECT_ID, proxySettings) self.file_type = file_type self.file_name = file_name self.new_name = new_name
) #Gets your Smartling credetnials from environment variables MY_USER_IDENTIFIER = credentials.MY_USER_IDENTIFIER MY_USER_SECRET = credentials.MY_USER_SECRET MY_PROJECT_ID = credentials.MY_PROJECT_ID MY_LOCALE = credentials.MY_LOCALE #set proxy settigns if necessary useProxy = False if useProxy: proxySettings = ProxySettings("login", "password", "proxy_host", "proxy_port") else: proxySettings = None #initializa api object fapi = SmartlingFileApiV2(MY_USER_IDENTIFIER, MY_USER_SECRET, MY_PROJECT_ID, proxySettings) #Upload file to Smartling print "\nUploading ..." path = FILE_PATH + FILE_NAME resp, code = fapi.upload(path, FILE_TYPE, authorize=True) print resp, code if 200 != code: raise "failed" #List uploaded files print "\nList ..." resp, code = fapi.list() print "items size= ", len(resp.data.items) print code, resp