supybot-wizard: Warn if run with ~/.local/bin as CWD.

This commit is contained in:
Valentin Lorentz 2018-04-11 11:57:06 +02:00
parent 6a8921fc64
commit f26f098d82
2 changed files with 15 additions and 0 deletions

View File

@ -184,6 +184,14 @@ def main():
'run directly in the HOME directory. ' 'run directly in the HOME directory. '
'You should not do this unless you want it to ' 'You should not do this unless you want it to '
'create multiple files in your HOME directory.') 'create multiple files in your HOME directory.')
parser.add_option('', '--allow-bin', action='store_true',
dest='allowBin',
help='Determines whether the wizard will be allowed to '
'run directly in a directory for binaries (eg. '
'/usr/bin, /usr/local/bin, or ~/.local/bin). '
'You should not do this unless you want it to '
'create multiple non-binary files in directory '
'that should only contain binaries.')
parser.add_option('', '--no-network', action='store_false', parser.add_option('', '--no-network', action='store_false',
dest='network', dest='network',
help='Determines whether the wizard will be allowed to ' help='Determines whether the wizard will be allowed to '
@ -195,6 +203,8 @@ def main():
if os.name == 'posix': if os.name == 'posix':
if (os.getcwd() == os.path.expanduser('~')) and not options.allowHome: if (os.getcwd() == os.path.expanduser('~')) and not options.allowHome:
error('Please, don\'t run this in your HOME directory.') error('Please, don\'t run this in your HOME directory.')
if (os.path.split(os.getcwd())[-1] == 'bin') and not options.allowBin:
error('Please, don\'t run this in a "bin" directory.')
if os.path.isfile(os.path.join('scripts', 'supybot-wizard')) or \ if os.path.isfile(os.path.join('scripts', 'supybot-wizard')) or \
os.path.isfile(os.path.join('..', 'scripts', 'supybot-wizard')): os.path.isfile(os.path.join('..', 'scripts', 'supybot-wizard')):
print('') print('')

View File

@ -221,6 +221,11 @@ class FunctionsTestCase(SupyTestCase):
self.assertTrue(max(map(pred, r)) <= 100) self.assertTrue(max(map(pred, r)) <= 100)
self.assertEqual(''.join(r), s) self.assertEqual(''.join(r), s)
s = uchr(233)*500
print(repr(ircutils.wrap(s, 500)))
import supybot.utils.str
print(repr(supybot.utils.str.byteTextWrap(s, 500)))
def testSafeArgument(self): def testSafeArgument(self):
s = 'I have been running for 9 seconds' s = 'I have been running for 9 seconds'