2015-07-11 12:00:55 +03:00
|
|
|
#-*- coding: utf-8 -*-
|
|
|
|
'''
|
2016-02-03 16:37:49 +03:00
|
|
|
python-libtorrent for Kodi (script.module.libtorrent)
|
|
|
|
Copyright (C) 2015-2016 DiMartino, srg70, RussakHH, aisman
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
a copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2015-07-11 12:00:55 +03:00
|
|
|
'''
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
2015-07-12 02:01:59 +03:00
|
|
|
from platform_pulsar import get_libname
|
2015-07-11 12:00:55 +03:00
|
|
|
|
|
|
|
class Public:
|
|
|
|
def __init__( self ):
|
2015-07-14 20:42:31 +03:00
|
|
|
self.platforms=[]
|
2015-07-11 12:00:55 +03:00
|
|
|
self.root=os.path.dirname(__file__)
|
2015-07-14 20:42:31 +03:00
|
|
|
for dir in os.listdir(self.root):
|
|
|
|
if os.path.isdir(os.path.join(self.root,dir)):
|
2015-08-02 16:04:40 +03:00
|
|
|
for subdir in os.listdir(os.path.join(self.root,dir)):
|
|
|
|
if os.path.isdir(os.path.join(self.root,dir,subdir)):
|
|
|
|
self.platforms.append({'system':dir, 'version':subdir})
|
2015-07-11 12:00:55 +03:00
|
|
|
self._generate_size_file()
|
|
|
|
|
|
|
|
def _generate_size_file( self ):
|
|
|
|
for platform in self.platforms:
|
|
|
|
for libname in get_libname(platform):
|
|
|
|
self.libname=libname
|
|
|
|
self.platform=platform
|
2015-08-02 16:04:40 +03:00
|
|
|
self.libdir = os.path.join(self.root, self.platform['system'], self.platform['version'])
|
2015-07-11 12:00:55 +03:00
|
|
|
self.libpath = os.path.join(self.libdir, self.libname)
|
|
|
|
self.sizepath=self.libpath+'.size.txt'
|
|
|
|
self.zipname=self.libname+'.zip'
|
2015-08-02 16:04:40 +03:00
|
|
|
zippath=os.path.join(self.libdir, self.zipname)
|
|
|
|
system=platform['system']+'/'+platform['version']+'/'
|
2015-07-11 12:00:55 +03:00
|
|
|
if os.path.exists(self.libpath):
|
|
|
|
if not os.path.exists(self.sizepath):
|
2015-08-02 16:04:40 +03:00
|
|
|
print system+self.libname+' NO SIZE'
|
2015-07-11 12:00:55 +03:00
|
|
|
self._makezip()
|
2015-08-02 16:04:40 +03:00
|
|
|
elif not os.path.exists(zippath):
|
|
|
|
print system+self.libname+' NO ZIP'
|
2015-07-11 12:00:55 +03:00
|
|
|
self._makezip()
|
|
|
|
else:
|
|
|
|
size=str(os.path.getsize(self.libpath))
|
|
|
|
size_old=open( self.sizepath, "r" ).read()
|
|
|
|
if size_old!=size:
|
2015-08-02 16:04:40 +03:00
|
|
|
print system+self.libname+' NOT EQUAL'
|
2015-07-11 12:00:55 +03:00
|
|
|
self._makezip()
|
|
|
|
else:
|
2015-08-02 16:04:40 +03:00
|
|
|
print system+self.libname+' NO ACTION'
|
2015-07-11 12:00:55 +03:00
|
|
|
else:
|
2015-08-02 16:04:40 +03:00
|
|
|
print system+self.libname+' NO LIB'
|
2015-07-11 12:00:55 +03:00
|
|
|
|
|
|
|
def _makezip(self):
|
|
|
|
open( self.sizepath, "w" ).write( str(os.path.getsize(self.libpath)) )
|
|
|
|
os.chdir(self.libdir)
|
|
|
|
os.system('del %s' % (self.zipname))
|
|
|
|
os.system('"C:\\Program Files\\7-Zip\\7z.exe" a %s.zip %s' %
|
|
|
|
(self.libname, self.libname))
|
|
|
|
os.chdir(self.root)
|
|
|
|
#os.system('"C:\\Program Files\\7-Zip\\7z.exe" a %s.zip %s' %
|
|
|
|
# (self.platform['system']+os.sep+self.libname, self.platform['system']+os.sep+self.libname))
|
|
|
|
|
|
|
|
if ( __name__ == "__main__" ):
|
|
|
|
# start
|
2015-07-11 23:49:53 +03:00
|
|
|
#TODO: publicate
|
2015-07-11 12:00:55 +03:00
|
|
|
Public()
|