Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thme 456 #30

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ab6056f
first run, error while writing to *.nzb file
Jul 17, 2013
ccc023b
added destructor to fileWrapper
Jul 18, 2013
1e55857
added initializing testcases
Jul 19, 2013
52f4443
minimal changes to gitignore
Jul 19, 2013
3b2b944
yenc working for python3 only
Jul 22, 2013
0efbb4e
-) fixes in yEnc_python3
Jul 22, 2013
50a341c
adapted testcases, beautifyed _yEncode_escape
Jul 22, 2013
a2324be
encapsulated _yenc_splitIntoLines
Jul 22, 2013
3ed9994
fixed write nzb file bug
Jul 23, 2013
13015b0
encapsulated mangler::main::parseCmdLineOption
Jul 23, 2013
2f7c5ea
restore python2.7+ compatibility
Jul 23, 2013
3aefde8
Merge nickma82 python3_support branch
nicors57 Apr 30, 2014
0f2e493
Cleaned files: removed and replaced tabs by spaces
nicors57 May 1, 2014
c81d721
Added SSL + new remaining time
nicors57 Apr 24, 2014
42a2e65
Minor fixes
nicors57 Apr 25, 2014
f5be9b8
Updated README.rst
nicors57 Apr 25, 2014
27d6cef
Added sample.conf
nicors57 Apr 25, 2014
548b506
Cleaned unused code
nicors57 Apr 25, 2014
29f91e6
Added ssl requirement in README and removed unused import
nicors57 Apr 26, 2014
d62c80b
Fixed Python3 support.
nicors57 Apr 26, 2014
82e9649
Improved remaining time. Added pretty size left.
nicors57 Apr 27, 2014
af577d6
Reduced select socket time. Fixed SSL WantWriteError on Windows
nicors57 Apr 27, 2014
918e312
TODO comment
nicors57 Apr 28, 2014
72f829e
Update postmangler.py
kwaaak Nov 2, 2014
9a6ad00
Merge pull request #1 from kwaaak/patch-1
nicors57 Mar 25, 2016
b6df3b7
add theme tetet
Jun 8, 2016
04e6984
hsgfyisdgfsdfsd dsqfre ggsgreqe qq gfd bfd
Jun 8, 2016
5875fa2
dgxg
Jun 8, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.nzb
*.pyc
*~
24 changes: 14 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
==================
**IMPORTANT NOTE**
==================
This project is no longer being actively maintained. It still works fine but no
new features will ever be appearing. Check out `my GoPostStuff project <https://github.com/madcowfred/GoPostStuff/>`_
for a new and much scarier version of the idea.



newsmangler
===========

newsmangler is a basic client for posting binaries to Usenet. The only notable
feature is multiple connection support to efficiently utilize modern bandwidth.
It supports SSL connection !

Requirements
============

Python 2.6 or newer (including Python 3).
For SSL connection you will need OpenSSL:
``pip install python-openssl`` or ``sudo aptitude install python-openssl`` (debian/ubuntu)

Installation
============
#. Download the source: ``git clone git://github.com/madcowfred/newsmangler.git``
#. Download the source: ``git clone git://github.com/nicors57/newsmangler.git``
(or download a .zip I guess).

#. Copy sample.conf to ~/.newsmangler.conf, edit the options as appropriate.
Expand Down Expand Up @@ -43,3 +42,8 @@ The files will post as:
``test post please ignore [3/3] - "test.part2.rar" yEnc (01/27)``

See ``python mangler.py --help`` for other options.

Notes
=====

Upload using Python3 is slower (~20%) than using python2.
214 changes: 111 additions & 103 deletions mangler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,118 +31,126 @@

import os
import sys
from ConfigParser import ConfigParser

from optparse import OptionParser

from newsmangler.common import ParseConfig
from newsmangler.postmangler import PostMangler

# ---------------------------------------------------------------------------

def main():
# Parse our command line options
parser = OptionParser(usage='usage: %prog [options] dir1 dir2 ... dirN')
parser.add_option('-c', '--config',
dest='config',
help='Specify a different config file location',
)
parser.add_option('-f', '--files',
dest='files',
help='Assume all arguments are filenames instead of directories, and use SUBJECT as the base subject',
metavar='SUBJECT',
)
parser.add_option('-g', '--group',
dest='group',
help='Post to a different group than the default',
)
# parser.add_option('-p', '--par2',
# dest='generate_par2',
# action='store_true',
# default=False,
# help="Generate PAR2 files in the background if they don't exist already.",
# )
parser.add_option('-d', '--debug',
dest='debug',
action='store_true',
default=False,
help="Enable debug logging",
)
parser.add_option('--profile',
dest='profile',
action='store_true',
default=False,
help='Run with the hotshot profiler (measures execution time of functions)',
)
def parseCmdLineOption():
# Parse our command line options
parser = OptionParser(usage='usage: %prog [options] dir1 dir2 ... dirN')
parser.add_option('-c', '--config',
dest='config',
help='Specify a different config file location',
)
parser.add_option('-f', '--files',
dest='files',
help='Assume all arguments are filenames instead of directories, \
and use SUBJECT as the base subject',
metavar='SUBJECT',
)
parser.add_option('-g', '--group',
dest='group',
help='Post to a different group than the default',
)
# parser.add_option('-p', '--par2',
# dest='generate_par2',
# action='store_true',
# default=False,
# help="Generate PAR2 files in the background if they don't exist already.",
# )
parser.add_option('-d', '--debug',
dest='debug',
action='store_true',
default=False,
help="Enable debug logging",
)
parser.add_option('--profile',
dest='profile',
action='store_true',
default=False,
help='Run with the hotshot profiler (measures execution time of functions)',
)

(options, args) = parser.parse_args()

# No args? We have nothing to do!
if not args:
parser.print_help()
sys.exit(1)

# Make sure at least one of the args exists
postme = []
post_title = None
if options.files:
post_title = options.files
for arg in args:
if os.path.isfile(arg):
postme.append(arg)
else:
print 'ERROR: "%s" does not exist or is not a file!' % (arg)
else:
for arg in args:
if os.path.isdir(arg):
postme.append(arg)
else:
print 'ERROR: "%s" does not exist or is not a file!' % (arg)

if not postme:
print 'ERROR: no valid arguments provided on command line!'
sys.exit(1)

# Parse our configuration file
if options.config:
conf = ParseConfig(options.config)
else:
conf = ParseConfig()

# Make sure the group is ok
if options.group:
if '.' not in options.group:
newsgroup = conf['aliases'].get(options.group)
if not newsgroup:
print 'ERROR: group alias "%s" does not exist!' % (options.group)
sys.exit(1)
else:
newsgroup = options.group
else:
newsgroup = conf['posting']['default_group']

# Strip whitespace from the newsgroup list to obey RFC1036
for c in (' \t'):
newsgroup = newsgroup.replace(c, '')

# And off we go
poster = PostMangler(conf, options.debug)

if options.profile:
import hotshot
prof = hotshot.Profile('profile.poster')
prof.runcall(poster.post, newsgroup, postme, post_title=post_title)
prof.close()

import hotshot.stats
stats = hotshot.stats.load('profile.poster')
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(25)

else:
poster.post(newsgroup, postme, post_title=post_title)
(options, args) = parser.parse_args()

# No args? We have nothing to do!
if not args:
parser.print_help()
sys.exit(1)

return (options, args)


def main():
(options, args) = parseCmdLineOption()

# Make sure at least one of the args exists
postme = []
post_title = None
if options.files:
post_title = options.files
for arg in args:
if os.path.isfile(arg):
postme.append(arg)
else:
print('ERROR: "%s" does not exist or is not a file!' % (arg))
else:
for arg in args:
if os.path.isdir(arg):
postme.append(arg)
else:
print('ERROR: "%s" does not exist or is not a file!' % (arg))

if not postme:
print('ERROR: no valid arguments provided on command line!')
sys.exit(1)

# Parse our configuration file
if options.config:
conf = ParseConfig(options.config)
else:
conf = ParseConfig()

# Make sure the group is ok
if options.group:
if '.' not in options.group:
newsgroup = conf['aliases'].get(options.group)
if not newsgroup:
print('ERROR: group alias "%s" does not exist!' % (options.group))
sys.exit(1)
else:
newsgroup = options.group
else:
newsgroup = conf['posting']['default_group']

# Strip whitespace from the newsgroup list to obey RFC1036
for c in (' \t'):
newsgroup = newsgroup.replace(c, '')

# And off we go
poster = PostMangler(conf, options.debug)

if options.profile:
# TODO: replace by cProfile (PY3 compatibility)
import hotshot
prof = hotshot.Profile('profile.poster')
prof.runcall(poster.post, newsgroup, postme, post_title=post_title)
prof.close()

import hotshot.stats
stats = hotshot.stats.load('profile.poster')
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(25)

else:
poster.post(newsgroup, postme, post_title=post_title)

# ---------------------------------------------------------------------------

if __name__ == '__main__':
main()
main()
Loading