Skip to content

Commit

Permalink
Merge branch 'develop' for v2.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
wwyaiykycnf committed Jun 26, 2014
2 parents 7b34fd1 + a3a9974 commit 44d4f8b
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
*.txt
*.pyc
downloads/
build/dist
build/build
3 changes: 3 additions & 0 deletions build/Run_e621dl_In_Windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
e621dl.exe
@echo off
pause
2 changes: 2 additions & 0 deletions build/clean.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@RD /S /Q build
@RD /S /Q dist
3 changes: 3 additions & 0 deletions build/make_msi.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python setup.py bdist --format=msi
@echo off
pause
17 changes: 17 additions & 0 deletions build/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from cx_Freeze import setup, Executable
import sys

sys.path.append('../')

from lib.version import VERSION

executables = [
Executable('../e621dl.py')
]

setup(name='e621dl',
version=VERSION,
description='the automated e621dl.net downloader',
data_files=[('.', ['Run_e621dl_In_Windows.bat'])],
executables=executables,
)
18 changes: 8 additions & 10 deletions e621dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import lib.e621_api as e621_api
from lib.downloader import multi_download
from lib.version import VERSION
from multiprocessing import freeze_support

if __name__ == '__main__':
freeze_support()

##############################################################################
# INITIALIZATION
Expand Down Expand Up @@ -46,11 +48,8 @@
EARLY_TERMINATE |= not os.path.isfile(CONFIG['tag_file'])
TAGS = support.get_tagfile(CONFIG['tag_file'])

# tags was read but contained nothing
if len(TAGS) == 0 and not EARLY_TERMINATE:
LOG.error('no tags found in %s', CONFIG['tag_file'])
LOG.error('add lines to this file and re-run program')
EARLY_TERMINATE |= True
# are there any tags in the tags file?
EARLY_TERMINATE |= not support.validate_tagfile(TAGS, CONFIG['tag_file'])

# open the cache (this can't really fail; just creates a new blank one)
CACHE = support.get_cache(CONFIG['cache_name'], CONFIG['cache_size'])
Expand All @@ -62,7 +61,7 @@
# exit before updating if any errors occurred in pre-update
if EARLY_TERMINATE:
LOG.error('error(s) encountered during initialization, see above')
exit()
sys.exit(-1)

##############################################################################
# UPDATE
Expand All @@ -86,10 +85,10 @@
current_page = 1
links_in_cache = 0
links_on_disk = 0
will_download = 0
potential_downloads = []

while accumulating:
LOG.debug('getting page %d', current_page)
links_found = e621_api.get_posts(line, CONFIG['last_run'],
current_page, default.MAX_RESULTS)

Expand All @@ -106,7 +105,6 @@
LOG.info('%d new uploads tagged: %s', len(potential_downloads), line)

if len(potential_downloads) > 0:
will_download = 0

# there were uploads. determine should any be downloaded
current = 0
Expand Down Expand Up @@ -140,7 +138,7 @@
TOTAL_DOWNLOADS += 1

LOG.debug('update for %s completed\n', line)
LOG.info('%5d total (%d new, %d existing, %d cached)\n',
LOG.info('%5d total (+%d new, %d existing, %d cached)\n',
TOTAL_DOWNLOADS, will_download, links_on_disk, links_in_cache)

if URL_AND_NAME_LIST:
Expand Down Expand Up @@ -169,4 +167,4 @@

LOG.info('last run updated to %s', CONFIG['last_run'])

exit()
sys.exit(0)
21 changes: 15 additions & 6 deletions lib/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ def get_verbosity_level():
def make_default_configfile(filename):
log = logging.getLogger('configfile')
log.error('new default file created: ' + filename)
log.error('verify this new config file and re-run the program')
log.error('\tverify this file and re-run the program')
with open(filename, 'w') as outfile:
json.dump(default.CONFIG_FILE, outfile, indent=4, sort_keys=True,)
return default.CONFIG_FILE

def get_configfile(filename):
log = logging.getLogger('configfile')
if not os.path.isfile(filename):
return make_default_configfile
return make_default_configfile(filename)
else:
with open(filename, 'r') as infile:
log.debug('opened ' + filename)
Expand All @@ -61,13 +61,14 @@ def make_default_tagfile(filename):
outfile.write(default.TAG_FILE)

log.error('new default file created: ' + filename)
log.error('please add tags you wish to this file and re-run the program')
log.error('\tadd to this file and re-run the program')

def get_tagfile(filename):
log = logging.getLogger('tag_file')

if not os.path.isfile(filename):
return make_default_configfile(filename)
make_default_tagfile(filename)
return default.TAG_FILE
else:
# read out all lines not starting with #
tag_list = []
Expand All @@ -76,8 +77,8 @@ def get_tagfile(filename):
if not raw_line.startswith("#") and raw_line != '':
tag_list.append(raw_line)

log.debug('opened %s and read %d items', filename, len(tag_list))
return tag_list
log.debug('opened %s and read %d items', filename, len(tag_list))
return tag_list

def get_cache(filename, size):
log = logging.getLogger('cache')
Expand Down Expand Up @@ -112,6 +113,14 @@ def safe_filename(tag_line, item, config_dict):

return safe_filename

def validate_tagfile(tags, filename):
if len(tags) == 0:
log = logging.getLogger('tag_file')
log.error('no tags found in %s', filename)
log.error('\tadd lines to this file and re-run program')
return False
return True

def validate_config(c):
log = logging.getLogger('config_file')
try:
Expand Down
2 changes: 1 addition & 1 deletion lib/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env python
VERSION = "2.3.5"
VERSION = "2.3.7"

0 comments on commit 44d4f8b

Please sign in to comment.