Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
evilhero committed Mar 3, 2015
2 parents f018742 + dea9ee7 commit 0fe5ce2
Show file tree
Hide file tree
Showing 39 changed files with 2,830 additions and 764 deletions.
77 changes: 68 additions & 9 deletions Mylar.py
Expand Up @@ -15,6 +15,8 @@
# along with Mylar. If not, see <http://www.gnu.org/licenses/>.

import os, sys, locale
import errno
import shutil
import time
import threading
import signal
Expand Down Expand Up @@ -64,6 +66,7 @@ def main():
parser.add_argument('-q', '--quiet', action='store_true', help='Turn off console logging')
parser.add_argument('-d', '--daemon', action='store_true', help='Run as a daemon')
parser.add_argument('-p', '--port', type=int, help='Force mylar to run on a specified port')
parser.add_argument('-b', '--backup', action='store_true', help='Will automatically backup & keep the last 2 copies of the .db & ini files prior to startup')
parser.add_argument('--datadir', help='Specify a directory where to store your data files')
parser.add_argument('--config', help='Specify a config file to use')
parser.add_argument('--nolaunch', action='store_true', help='Prevent browser from launching on startup')
Expand All @@ -85,7 +88,6 @@ def main():
# except Exception, e:
# sys.exit('Mylar failed to update.')


if args.daemon:
if sys.platform == 'win32':
print "Daemonize not supported under Windows, starting normally"
Expand Down Expand Up @@ -142,6 +144,47 @@ def main():
# Put the database in the DATA_DIR
mylar.DB_FILE = os.path.join(mylar.DATA_DIR, 'mylar.db')

# backup the db and configs before they load.
if args.backup:
print '[AUTO-BACKUP] Backing up .db and config.ini files for safety.'
backupdir = os.path.join(mylar.DATA_DIR, 'backup')

try:
os.makedirs(backupdir)
print '[AUTO-BACKUP] Directory does not exist for backup - creating : ' + backupdir
except OSError as exception:
if exception.errno != errno.EEXIST:
print '[AUTO-BACKUP] Directory already exists.'
raise

i = 0
while (i < 2):
if i == 0:
ogfile = mylar.DB_FILE
back = os.path.join(backupdir, 'mylar.db')
back_1 = os.path.join(backupdir, 'mylar.db.1')
else:
ogfile = mylar.CONFIG_FILE
back = os.path.join(backupdir, 'config.ini')
back_1 = os.path.join(backupdir, 'config.ini.1')

try:
print '[AUTO-BACKUP] Now Backing up mylar.db file'
if os.path.isfile(back_1):
print '[AUTO-BACKUP] ' + back_1 + ' exists. Deleting and keeping new.'
os.remove(back_1)
if os.path.isfile(back):
print '[AUTO-BACKUP] Now renaming ' + back + ' to ' + back_1
shutil.move(back, back_1)
print '[AUTO-BACKUP] Now copying db file to ' + back
shutil.copy(ogfile, back)

except OSError as exception:
if exception.errno != errno.EXIST:
raise

i+=1

mylar.CFG = ConfigObj(mylar.CONFIG_FILE, encoding='utf-8')

# Rename the main thread
Expand All @@ -160,16 +203,32 @@ def main():
else:
http_port = int(mylar.HTTP_PORT)

# Check if pyOpenSSL is installed. It is required for certificate generation
# and for CherryPy.
if mylar.ENABLE_HTTPS:
try:
import OpenSSL
except ImportError:
logger.warn("The pyOpenSSL module is missing. Install this " \
"module to enable HTTPS. HTTPS will be disabled.")
mylar.ENABLE_HTTPS = False

# Try to start the server. Will exit here is address is already in use.
web_config = {
'http_port': http_port,
'http_host': mylar.HTTP_HOST,
'http_root': mylar.HTTP_ROOT,
'enable_https': mylar.ENABLE_HTTPS,
'https_cert': mylar.HTTPS_CERT,
'https_key': mylar.HTTPS_KEY,
'http_username': mylar.HTTP_USERNAME,
'http_password': mylar.HTTP_PASSWORD,
}

# Try to start the server.
webstart.initialize({
'http_port': http_port,
'http_host': mylar.HTTP_HOST,
'http_root': mylar.HTTP_ROOT,
'http_username': mylar.HTTP_USERNAME,
'http_password': mylar.HTTP_PASSWORD,
})
webstart.initialize(web_config)

logger.info('Starting Mylar on port: %i' % http_port)
#logger.info('Starting Mylar on port: %i' % http_port)

if mylar.LAUNCH_BROWSER and not args.nolaunch:
mylar.launch_browser(mylar.HTTP_HOST, http_port, mylar.HTTP_ROOT)
Expand Down
45 changes: 28 additions & 17 deletions data/interfaces/default/comicdetails.html
Expand Up @@ -146,11 +146,11 @@ <h3><i>(Comic information is currently being loaded)</i></h3>
archive_path = 'None'
%>
%if os.path.exists(archive_path) and archive_path != comic['ComicLocation']:
<label><big>Directories</big><br/>
<norm>Primary: ${comic['ComicLocation']}</norm></label>
<norm>Secondary: ${archive_path}</norm></label>
<label><big>Directories:</big></label><br/>
<p class="tab"><norm>Primary: ${comic['ComicLocation']}</norm><br/>
<norm>Secondary: ${archive_path}</norm></label></p>
%else:
<label><big>Directory</big><br/>
<label><big>Directory:</big><br/>
<norm>${comic['ComicLocation']}</norm></label>
%endif
%else:
Expand Down Expand Up @@ -292,6 +292,14 @@ <h3><i>(Comic information is currently being loaded)</i></h3>
<a href="#" title="Seperate multiple entries with ##"><img src="interfaces/default/images/info32.png" height="16" alt="" /></a>
<small>Alternate comic names to be searched in case naming is different (ie. Hack/Slash = hack-slash)</small>
</div>

<div class="row">
<label>Alternate File-Naming</label>
<input type="text" name="alt_filename" value="${comic['AlternateFileName']}" size="90">
<a href="#" title="Alternate File Naming"><img src="interfaces/default/images/info32.png" height="16" alt="" /></a>
<small>Alternate file-naming to be used when post-processing / renaming files instead of the actual title.</small>
</div>

<div class="row">
<%
year_options = "Default - Keep the Year as is\nYear Removal - Remove issue publication year from searches (dangerous)\nFuzzy the Year - Increase & Decrease the issue publication year by one"
Expand Down Expand Up @@ -335,7 +343,6 @@ <h3><i>(Comic information is currently being loaded)</i></h3>
<option disabled="disabled" selected="selected">Choose...</option>
<option value="Wanted">Wanted</option>
<option value="Skipped">Skipped</option>
<option value="Downloaded">Downloaded</option>
<option value="Archived">Archived</option>
<option value="Ignored">Ignored</option>
%if mylar.FAILED_DOWNLOAD_HANDLING:
Expand Down Expand Up @@ -429,7 +436,7 @@ <h3><i>(Comic information is currently being loaded)</i></h3>
%if linky:
<a href="downloadthis?pathfile=${linky |u}"><img src="interfaces/default/images/download_icon.png" height="25" width="25" title="Download the Issue" class="highqual" /></a>
%if linky.endswith('.cbz'):
<a href="#issue-box" onclick="return runMetaIssue('${linky}');" class="issue-window"><img src="interfaces/default/images/issueinfo.png" height="25" width="25" title="View Issue Details" class="highqual" /></a>
<a href="#issue-box" onclick="return runMetaIssue('${linky |u}');" class="issue-window"><img src="interfaces/default/images/issueinfo.png" height="25" width="25" title="View Issue Details" class="highqual" /></a>
<div id="issue-box" class="issue-popup">
<a href="#" class="close"><img src="interfaces/default/images/close_pop.png" class="btn_close" title="Close Window" alt="Close" class="highqual" /></a>
<fieldset>
Expand All @@ -441,7 +448,7 @@ <h3><i>(Comic information is currently being loaded)</i></h3>
%endif

%if mylar.ENABLE_META:
<a href="#" title="Manually meta-tag issue" onclick="doAjaxCall('manual_metatag?dirName=${comic['ComicLocation'] |u}&issueid=${issue['IssueID']}&filename=${linky |u}&comicid=${issue['ComicID']}',$(this),'table')" data-success="${issue['Issue_Number']} successfully tagged."><img src="interfaces/default/images/comictagger.png" height="25" width="25" class="highqual" /></a>
<a href="#" title="Manually meta-tag issue" onclick="doAjaxCall('manual_metatag?dirName=${comic['ComicLocation'] |u}&issueid=${issue['IssueID']}&filename=${linky |u}&comicid=${issue['ComicID']}&comversion=${comic['ComicVersion']}',$(this),'table')" data-success="${issue['Issue_Number']} successfully tagged."><img src="interfaces/default/images/comictagger.png" height="25" width="25" class="highqual" /></a>
%endif
%endif
<!--
Expand Down Expand Up @@ -511,19 +518,23 @@ <h1>Annuals</h1>

<%
if annual['Status'] == 'Skipped':
grade = 'Z'
agrade = 'Z'
elif annual['Status'] == 'Wanted':
grade = 'X'
agrade = 'X'
elif annual['Status'] == 'Snatched':
grade = 'C'
agrade = 'C'
elif annual['Status'] == 'Downloaded':
grade = 'A'
agrade = 'A'
elif annual['Status'] == 'Archived':
grade = 'A'
agrade = 'A'
elif annual['Status'] == 'Ignored':
agrade = 'A'
elif annual['Status'] == 'Failed':
agrade = 'C'
else:
grade = 'A'
agrade = 'A'
%>
<tr class="${annual['Status']} grade${grade}">
<tr class="${annual['Status']} grade${agrade}">
<td id="select"><input type="checkbox" name="${annual['IssueID']}" class="checkbox" value="${annual['IssueID']}" /></td>
<%
if annual['Int_IssueNumber'] is None:
Expand All @@ -546,7 +557,7 @@ <h1>Annuals</h1>
<% amode = 'want_ann' %>
<a href="#" title="Manual Search" onclick="doAjaxCall('queueit?ComicID=${annual['ComicID']}&IssueID=${annual['IssueID']}&ComicIssue=${annual['Issue_Number']}&ComicYear=${annual['IssueDate']}&mode=${amode}&manualsearch=True',$(this),'table')" data-success="Manually searching for ${annual['ComicName']} #${annual['Issue_Number']}"><img src="interfaces/default/images/search.png" height="25" width="25" class="highqual" /></a>
%if annual['Status'] == 'Skipped' or annual['Status'] == 'Ignored':
<a href="#" title="Mark annual as Wanted" onclick="doAjaxCall('queueissue?ComicID=${annual['ComicID']}&IssueID=${annual['IssueID']}&ComicIssue=${annual['Issue_Number']}&ComicYear=${annual['IssueDate']}&mode=${amode}',$(this),'table')"><img src="interfaces/default/images/wanted_icon.png" height="25" width="25" class="highqual" /></a>
<a href="#" title="Mark annual as Wanted" onclick="doAjaxCall('queueit?ComicID=${annual['ComicID']}&IssueID=${annual['IssueID']}&ComicIssue=${annual['Issue_Number']}&ComicYear=${annual['IssueDate']}&mode=${amode}',$(this),'table')" data-success="Marked ${annual['ReleaseComicName']} #${annual['Issue_Number']} as Wanted"><img src="interfaces/default/images/wanted_icon.png" height="25" width="25" class="highqual" /></a>
%elif (annual['Status'] == 'Wanted'):
<a href="#" title="Mark annual as Skipped" onclick="doAjaxCall('unqueueissue?IssueID=${annual['IssueID']}&ComicID=${annual['ComicID']}&ReleaseComicID=${annual['ReleaseComicID']}',$(this),'table')" data-success="'${annual['Issue_Number']}' has been marked as skipped"><img src="interfaces/default/images/skipped_icon.png" height="25" width="25" class="highqual" /></a>
%elif (annual['Status'] == 'Snatched'):
Expand All @@ -567,7 +578,7 @@ <h1>Annuals</h1>
%if linky:
<a href="downloadthis?pathfile=${linky |u}"><img src="interfaces/default/images/download_icon.png" height="25" width="25" title="Download the annual" class="highqual" /></a>
%if linky.endswith('.cbz'):
<a href="#issue-box" onclick="return runMetaIssue('${linky}');" class="issue-window"><img src="interfaces/default/images/issueinfo.png" height="25" width="25" title="View Issue Details" class="highqual" /></a>
<a href="#issue-box" onclick="return runMetaIssue('${linky |u}');" class="issue-window"><img src="interfaces/default/images/issueinfo.png" height="25" width="25" title="View Issue Details" class="highqual" /></a>
<div id="issue-box" class="issue-popup">
<a href="#" class="close"><img src="interfaces/default/images/close_pop.png" class="btn_close" title="Close Window" alt="Close" class="highqual" /></a>
<fieldset>
Expand Down Expand Up @@ -686,7 +697,7 @@ <h1>Annuals</h1>

<script>
function runMetaIssue(filelink) {
alert(filelink);
// alert(filelink);
$.ajax({
type: "GET",
url: "IssueInfo",
Expand Down

0 comments on commit 0fe5ce2

Please sign in to comment.