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


Python Mega.login方法代码示例

本文整理汇总了Python中mega.Mega.login方法的典型用法代码示例。如果您正苦于以下问题:Python Mega.login方法的具体用法?Python Mega.login怎么用?Python Mega.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mega.Mega的用法示例。


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

示例1: test

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
def test():
    # user details
    email = "[email protected]"
    password = "password"

    mega = Mega()

    # login
    m = mega.login(email, password)

    # get user details
    details = m.get_user()
    print(details)

    # get account files
    files = m.get_files()
    print(files)

    # upload file
    print(m.upload("test.py"))

    # trash a file, by id or url
    # print(m.delete('f14U0JhD'))
    # print(m.delete_url('https://mega.co.nz/#!f14U0JhD!S_2k-EvB5U1N3s0vm3I5C0JN2toHSGkVf0UxQsiKZ8A'))

    # download file, by id+key or url
    # m.download('6hBW0R4a','By7-Vjj5xal8K5w_IXH3PlGNyZ1VvIrjZkOmHGq1X00')
    m.download_url("https://mega.co.nz/#!6hBW0R4a!By7-Vjj5xal8K5w_IXH3PlGNyZ1VvIrjZkOmHGq1X00")
开发者ID:bussiere,项目名称:mega.py,代码行数:30,代码来源:test.py

示例2: __init__

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
    def __init__(self, *args, **kwargs):
        usuario, senha = settings.MEGA['email'], settings.MEGA['password']

        mega = Mega({'verbose': True})
        self.m = mega.login(usuario, senha)

        super(Command, self).__init__(*args, **kwargs)
开发者ID:gustavosf,项目名称:cdzforever.net,代码行数:9,代码来源:syncfiles.py

示例3: test

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
def test():
    #user details
    email = '[email protected]'
    password = 'password'

    mega = Mega()

    #login
    m =  mega.login(email, password)

    #get user details
    details = m.get_user()
    print(details)

    #get account files
    files = m.get_files()
    #example iterate over files
    for file in files:
        if files[file]['a'] != False:
            print files[file]

    #upload file
    print(m.upload('test.py'))

    #trash a file, by id or url
    #print(m.delete('f14U0JhD'))
    #print(m.delete_url('https://mega.co.nz/#!f14U0JhD!S_2k-EvB5U1N3s0vm3I5C0JN2toHSGkVf0UxQsiKZ8A'))

    #download file, by id+key or url
    #m.download('6hBW0R4a','By7-Vjj5xal8K5w_IXH3PlGNyZ1VvIrjZkOmHGq1X00')
    m.download_url('https://mega.co.nz/#!6hBW0R4a!By7-Vjj5xal8K5w_IXH3PlGNyZ1VvIrjZkOmHGq1X00')
开发者ID:si73,项目名称:mega.py,代码行数:33,代码来源:test.py

示例4: test

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
def test():
    """
    Enter your account details to begin
    comment/uncomment lines to test various parts of the API
    see readme.md for more information
    """

    #user details
    email = '[email protected]'
    password = 'password'

    mega = Mega()
    #mega = Mega({'verbose': True})  # verbose option for print output

    # login
    m = mega.login(email, password)

    # get user details
    details = m.get_user()
    print(details)

    # get account files
    files = m.get_files()

    # get account disk quota in MB
    print(m.get_quota())
    # get account storage space
    print(m.get_storage_space())

    # example iterate over files
    for file in files:
        print(files[file])

    # upload file
    print(m.upload('examples.py'))

    # search for a file in account
    file = m.find('examples.py')

    if file:
        # get public link
        link = m.get_link(file)
        print(link)

        # download file. by file object or url
        print m.download(file, '/tmp')
        #m.download_url(link)

        #delete or destroy file. by id or url
        print(m.delete(file[0]))
        #print(m.destroy(file[0]))
        #print(m.delete_url(link))
        #print(m.destroy_url(link))

    # empty trash
    print(m.empty_trash())
开发者ID:Ilgrim,项目名称:mega.py,代码行数:58,代码来源:examples.py

示例5: do_put

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
 def do_put(self,filel):
   mega = Mega()
   m = mega.login('[email protected]','raghavan')
   self.filel=filel
   for i in self.filel:
    try:
     file1 = m.upload(i)
    except:
     file1 = m.upload(i)
    os.remove(i)
开发者ID:koshikraj,项目名称:master-cloud,代码行数:12,代码来源:main.py

示例6: do_get

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
 def do_get(self,filel):
   mega = Mega()
   m = mega.login('[email protected]','raghavan')
   self.file=filel
   try:
     file1=m.find(self.file)
     m.download(file1)
   except:
     file1=m.find(self.file)
     m.download(file1)
开发者ID:koshikraj,项目名称:master-cloud,代码行数:12,代码来源:main.py

示例7: megaUpload

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
def megaUpload(userName, password, fileName, destination, error=0):
    if error <> 0:
        print "Upload try n°" + str(error)
        print "Failed will try again in " + str(error*5) + " seconds"
    try:
        #Si on en est pas au premier essai on att 5 sec * le nombre d'essais
        time.sleep(5*error)
        mega = Mega()
        m = mega.login(userName, password)
        file = m.upload(fileName, m.find(destination)[0])
        return m.get_upload_link(file)
    except Exception, e:
        mega = Mega()
        m = mega.login(userName, password)
        file = m.find(fileName)
        if (file <> None):
            return m.get_upload_link(file)
        else:
            print "error : " , e
            megaUpload(userName, password, fileName, destination, error+1)
开发者ID:sidewinder94,项目名称:downloadFromItEbooks,代码行数:22,代码来源:downloadFromItEbooks.py

示例8: mega_login

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
def mega_login(user=None, passwd=None):
    """ Login to mega.co.nz
    """

    global MEGA_OBJ

    try:
        mega = Mega({'verbose': True})
        MEGA_OBJ = mega.login(user, passwd)
    except Exception as error: #TODO: Find actual exception
        LOGGER.error('Failed to login to mega.co.nz '
                'check username or password.\n' + str(error))
        sys.exit(1)
开发者ID:peterfisher,项目名称:mega-sync,代码行数:15,代码来源:mega_sync.py

示例9: mega_upload_files

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
def mega_upload_files(root, files, dest=None):
    mega = Mega()
    m = mega.login(config.get_username(), config.get_password())

    for filename in files:
        current = os.path.join(root, filename)
        print("Uploading: " + str(current))
        uploaded = m.upload(current)
        print(m.get_upload_link(uploaded))

        if dest != None:
            fileRef = m.find(filename)
            folder = m.find(dest)
            m.move(fileRef[0], folder)
开发者ID:jorgarga,项目名称:megauploader,代码行数:16,代码来源:megauploader.py

示例10: test

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
def test():
    #user details
    email = '[email protected]'
    password = 'password'

    mega = Mega()

    #login
    m = mega.login(email, password)

    #get user details
    details = m.get_user()
    print(details)

    #get account files
    files = m.get_files()

    #get account disk quota in MB
    print(m.get_quota())

    #example iterate over files
    for file in files:
        print(files[file])

    #upload file
    print(m.upload('tests.py'))

    #search for a file in account
    file = m.find('tests.py')


    if file:
        #get public link
        link = m.get_link(file)
        print(link)

        #download file. by file object or url
        m.download(file, '/tmp')
        #m.download_url(link)

        #delete or destroy file. by id or url
        print(m.delete(file[0]))
        #print(m.destroy(file[0]))
        #print(m.delete_url(link))
        #print(m.destroy_url(link))

    #empty trash
    print(m.empty_trash())
开发者ID:SigmoidFreud,项目名称:mega.py,代码行数:50,代码来源:tests.py

示例11: MegaDriver

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
class MegaDriver(Driver):
    def __init__(self, verbose=True):
        super(MegaDriver, self).__init__()
        # add the verbose option for print output on some functions
        self.mega = Mega({'verbose': verbose})

    def acquire_access_token(self, guest=False):
        email = raw_input('Enter your account email: ').strip()
        password = raw_input('Enter your account password: ').strip()
        self.parser.set('mega', 'email', email)
        self.parser.set('mega', 'password', password)
        with open(self.config_path, "w") as f:
            self.parser.write(f)

    def connect(self, include_guest=False):
        email = self.parser.get("mega", "email")
        password = self.parser.get("mega", "password")
        self.mega_service = self.mega.login(email, password)

    def download(self, remote_filename, local_filename=None):
        mega_file = self.mega_service.find(remote_filename)
        if local_filename:
            local_dir = os.path.dirname(local_filename)
            local_file_basename = ntpath.basename(local_filename)
            return self.mega_service.download(mega_file, local_dir, local_file_basename)
        else:
            self.mega_service.download(mega_file)

    def upload(self, local_filename, remote_filename=None):
        """upload a local file to Mega

        Args:
            local_filename: local file name
            remote_filename: not used here because of interface
        """
        return self.mega_service.upload(local_filename)

    def share(self, host_filename, guest_filename):
        raise NotImplementedError()
开发者ID:zenja,项目名称:benchmarking-cloud-storage-systems,代码行数:41,代码来源:mega_driver.py

示例12: test

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
def test():
    #user details
    email = '[email protected]'
    password = 'password'

    mega = Mega()

    ##login
    m = mega.login(email, password)

    ##get user details
    details = m.get_user()
    print(details)

    ##get account files
    files = m.get_files()
    #example iterate over files
    for file in files:
        if files[file]['a'] != False:
            print files[file]

    ##upload file
    print(m.upload('test.py'))

    ##get file's public link
    #NOTE: if passing upload() function response use get_upload_link()
    file = m.find('test.py')
    #print(m.get_upload_link(file))
    print(m.get_link(file))

    ##trash a file, by id or url
    #print(m.delete('f14U0JhD'))
    #print(m.delete_url('https://mega.co.nz/#!f14U0JhD!S_2k-EvB5U1N3s0vm3I5C0JN2toHSGkVf0UxQsiKZ8A'))

    ##search for a file in account
    file = m.find('somefile.doc')
    if file:
        #trash a file by it's id
        print(m.delete(file[1]['k']))
开发者ID:carlesso,项目名称:mega.py,代码行数:41,代码来源:test.py

示例13: login

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
 def login(cls):
     mega = Mega()
     cls.m = mega.login(os.environ.get('MEGA_EMAIL'), os.environ.get('MEGA_PASSWORD'))
开发者ID:Tefnet,项目名称:mega.py,代码行数:5,代码来源:test_api.py

示例14: Mega

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
import os
import sys
import ConfigParser
from mega import Mega

configfile = os.path.expanduser("~") + os.sep + '.megarc'
if not os.path.exists(configfile):
	sys.exit('File ~/.megarc Not Found!')

config = ConfigParser.RawConfigParser()
config.read(configfile)
email = config.get('default', 'email')
passw = config.get('default', 'pass')

mega = Mega({'verbose': True})
m = mega.login(email, passw)

files = m.get_files()
for f in files:
	filename = files[f]['a']['n']

	print(files[f])

	if files[f]['t']==0:
		print filename
		print m.get_link( m.find( filename ) )
	else:
		print 'Dir: '+filename
	print
开发者ID:stefanocudini,项目名称:Mega-Python-CommandLine-Tools,代码行数:31,代码来源:mega-list.py

示例15: Mega

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import login [as 别名]
from mega import Mega
import sys
import os

"""
This tool uploads a file to MEGA.CO.NZ
"""

if (len(sys.argv) != 4):
    print "usage: mega-upload.py <email> <password> <filepath>"
    sys.exit()

EMAIL = sys.argv[1]
PASSWORD = sys.argv[2]
FILEPATH = sys.argv[3]
FILENAME = os.path.basename(FILEPATH)

mega = Mega({'verbose': False}) 

# login
print 'login as '+EMAIL+'...'
m = mega.login(EMAIL, PASSWORD)

print 'uploading file to Mega...'
# upload file
m.upload(FILEPATH, dest_filename=FILENAME)
print 'upload OK'

开发者ID:tapionx,项目名称:mega-backup,代码行数:29,代码来源:mega-upload.py


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