Skip to content

Commit

Permalink
Fix whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankpatibandla committed Oct 18, 2023
1 parent 9578627 commit 141f50b
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 80 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ jobs:
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
Expand All @@ -61,7 +61,7 @@ jobs:
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ jobs:
- uses: actions/checkout@v3.1.0
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4.3.0
with:
python-version: 3.9
cache: 'pip'
if: matrix.os != 'macos-latest'

- name: Setup Python MacOS
run: |
wget https://www.python.org/ftp/python/3.10.11/python-3.10.11-macos11.pkg
sudo installer -verbose -pkg ./python-3.10.11-macos11.pkg -target /
echo "/Library/Frameworks/Python.framework/Versions/3.10/bin" >> $GITHUB_PATH
if: matrix.os == 'macos-latest'

- name: Install Requirements
run: python3 -m pip install --upgrade pip && pip3 install wheel && pip3 install -r requirements.txt && pip3 uninstall -y typing

- name: Build Wheel
run: python3 setup.py bdist_wheel
if: matrix.os == 'ubuntu-latest'
Expand All @@ -59,7 +59,7 @@ jobs:
name: pros-cli-wheel-${{needs.update_build_number.outputs.output1}}
path: dist/*
if: matrix.os == 'ubuntu-latest'

- name: Run Pyinstaller
run: |
python3 version.py
Expand All @@ -78,7 +78,7 @@ jobs:
pyinstaller --onefile pros/cli/compile_commands/intercept-cc.py --name=intercept-cc --target-arch=universal2
pyinstaller --onefile pros/cli/compile_commands/intercept-cc.py --name=intercept-c++ --target-arch=universal2
if: matrix.os == 'macos-latest'

- name: Package Everything Up
shell: bash
run: |
Expand Down
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: mixed-line-ending
args: [--fix=lf]
- id: end-of-file-fixer
- id: check-yaml
- id: check-vcs-permalinks
- id: check-merge-conflict
- id: check-case-conflict
- id: check-ast
- id: trailing-whitespace
- id: requirements-txt-fixer
- repo: local
hooks:
- id: pylint
Expand Down
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ max-line-length = 120

disable = C0114, C0115, C0116, R0903, C0415, R1705, R0913, W1203, R1729, E1120, E1123, C0209, R1710, W0621, C0121,
W0614, W0401, W1202, C0117, W0718, R0205, R0402, R0914, R1725, R1735, C0411, W0237, W0702, W0223, W0613,
W0108, R0912, R0911, W0511, E1136, R0902, W0611, C0412, C0103, C0301, R1732, R0915, W1514, R1718, W1510,
W0108, R0912, R0911, W0511, E1136, R0902, W0611, C0412, C0103, C0301, R1732, R0915, W1514, R1718, W1510,
E0602, W1309, C0325, E1101, R1714, R0916, W0719, R1734, E1133, W1201, W0107, W3101, W0640, C0201, W1113,
W0246, W0622, W0221, E1111, R1720, W0221, R1723, E0102, W0201, E0203, E0401, W0602, W0212, W0707, R0904,
W0101, C0302, E0110, W0603, R1701, W0106, R1721
W0101, C0302, E0110, W0603, R1701, W0106, R1721
2 changes: 1 addition & 1 deletion pip_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.2
3.4.2
2 changes: 1 addition & 1 deletion pros/cli/click_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ def invoke(self, *args, **kwargs):
if (isProject): #check if there is a project
curr_proj = p()
click.echo("PROS-Kernel Version: {}".format(curr_proj.kernel))
raise e
raise e
2 changes: 1 addition & 1 deletion pros/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def callback(ctx: click.Context, param: click.Parameter, value: bool):
if value:
echo("Not sending analytics for this command.\n")
analytics.useAnalytics = False
pass
pass
decorator = click.option('--no-analytics', expose_value=False, is_flag=True, default=False, is_eager=True,
help="Don't send analytics for this command.", callback=callback, cls=PROSOption, hidden=True)(f)
decorator.__name__ = f.__name__
Expand Down
5 changes: 2 additions & 3 deletions pros/cli/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
if version.lower() == 'latest' or not version:
version = '>0'
if not force_system and c.Project.find_project(path) is not None:
logger(__name__).error('A project already exists in this location at ' + c.Project.find_project(path) +
logger(__name__).error('A project already exists in this location at ' + c.Project.find_project(path) +
'! Delete it first. Are you creating a project in an existing one?', extra={'sentry': False})
ctx.exit(-1)
try:
Expand Down Expand Up @@ -311,7 +311,7 @@ def info_project(project: c.Project, ls_upgrades):
Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
"""
analytics.send("info-project")
analytics.send("info-project")
from pros.conductor.project import ProjectReport
report = ProjectReport(project)
_conductor = c.Conductor()
Expand Down Expand Up @@ -366,4 +366,3 @@ def query_depots(url: bool):
_conductor = c.Conductor()
ui.echo(f"Available Depots{' (Add --url for the url)' if not url else ''}:\n")
ui.echo('\n'.join(_conductor.query_depots(url))+"\n")

4 changes: 2 additions & 2 deletions pros/cli/misc_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def upgrade(force_check, no_install):
"""
with ui.Notification():
ui.echo('The "pros upgrade" command is currently non-functioning. Did you mean to run "pros c upgrade"?', color='yellow')

return # Dead code below

analytics.send("upgrade")
from pros.upgrade import UpgradeManager
manager = UpgradeManager()
Expand Down
4 changes: 2 additions & 2 deletions pros/cli/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def terminal(port: str, backend: str, **kwargs):
may be preferred when "share" doesn't perform adequately.
Note: share backend is not yet implemented.
"""
"""
analytics.send("terminal")
from pros.serial.devices.vex.v5_user_device import V5UserDevice
from pros.serial.terminal import Terminal
Expand Down Expand Up @@ -91,7 +91,7 @@ def __init__(self, file):
self.log = open(file, 'a')
def write(self, data):
self.terminal.write(data)
self.log.write(data)
self.log.write(data)
def flush(self):
pass
def end(self):
Expand Down
14 changes: 7 additions & 7 deletions pros/cli/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def upload_cli():
cls=PROSDeprecated, replacement='after')
@click.option('--run-screen/--execute', 'run_screen', default=None, help='Display run program screen on the brain after upload.',
cls=PROSDeprecated, replacement='after')
@click.option('-af', '--after', type=click.Choice(['run','screen','none']), default=None, help='Action to perform on the brain after upload.',
@click.option('-af', '--after', type=click.Choice(['run','screen','none']), default=None, help='Action to perform on the brain after upload.',
cls=PROSOption, group='V5 Options')
@click.option('--quirk', type=int, default=0)
@click.option('--name', 'remote_name', type=str, default=None, required=False, help='Remote program name.',
Expand All @@ -37,9 +37,9 @@ def upload_cli():
cls=PROSOption, group='V5 Options', hidden=True)
@click.option('--compress-bin/--no-compress-bin', 'compress_bin', cls=PROSOption, group='V5 Options', default=True,
help='Compress the program binary before uploading.')
@click.option('--description', default="Made with PROS", type=str, cls=PROSOption, group='V5 Options',
@click.option('--description', default="Made with PROS", type=str, cls=PROSOption, group='V5 Options',
help='Change the description displayed for the program.')
@click.option('--name', default=None, type=str, cls=PROSOption, group='V5 Options',
@click.option('--name', default=None, type=str, cls=PROSOption, group='V5 Options',
help='Change the name of the program.')

@default_options
Expand Down Expand Up @@ -119,12 +119,12 @@ def upload(path: Optional[str], project: Optional[c.Project], port: str, **kwarg
kwargs['remote_name'] = os.path.splitext(os.path.basename(path))[0]
kwargs['remote_name'] = kwargs['remote_name'].replace('@', '_')
kwargs['slot'] -= 1

action_to_kwarg = {
'run' : vex.V5Device.FTCompleteOptions.RUN_IMMEDIATELY,
'screen' : vex.V5Device.FTCompleteOptions.RUN_SCREEN,
'run' : vex.V5Device.FTCompleteOptions.RUN_IMMEDIATELY,
'screen' : vex.V5Device.FTCompleteOptions.RUN_SCREEN,
'none' : vex.V5Device.FTCompleteOptions.DONT_RUN
}
}
after_upload_default = 'screen'
#Determine which FTCompleteOption to assign to run_after
if kwargs['after']==None:
Expand Down
4 changes: 2 additions & 2 deletions pros/conductor/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def resolve_templates(self, identifier: Union[str, BaseTemplate], allow_online:
results.extend(online_results)
logger(__name__).debug('Saving Conductor config after checking for remote updates')
self.save() # Save self since there may have been some updates from the depots

return list(results)

def resolve_template(self, identifier: Union[str, BaseTemplate], **kwargs) -> Optional[BaseTemplate]:
Expand Down Expand Up @@ -340,6 +340,6 @@ def add_depot(self, name: str, url: str):
def remove_depot(self, name: str):
del self.depots[name]
self.save()

def query_depots(self, url: bool):
return [name + ((' -- ' + depot.location) if url else '') for name, depot in self.depots.items()]
8 changes: 4 additions & 4 deletions pros/conductor/depots.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $ pros conduct add-depot test "https://pros.cs.purdue.edu/v5/_static/beta/testin
`pros conduct remove-depot <name-of-your-depot>`

Example:
```bash
```bash
$ pros conduct remove-depot test
> Removed depot test
```
Expand All @@ -28,11 +28,11 @@ Examples:
```bash
$ pros conduct query-depots --url
> Available Depots:
>
>
> kernel-beta-mainline -- https://raw.githubusercontent.com/purduesigbots/pros-mainline/master/beta/kernel-beta-mainline.json
> pros-mainline -- https://purduesigbots.github.io/pros-mainline/pros-mainline.json
> test -- https://pros.cs.purdue.edu/v5/_static/beta/testing-mainline.json
>
>
```
```bash
$ pros conduct query-depots
Expand All @@ -41,5 +41,5 @@ $ pros conduct query-depots
> kernel-beta-mainline
> pros-mainline
> test
>
>
```
2 changes: 1 addition & 1 deletion pros/conductor/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def libscanbuild_capture(args: argparse.Namespace) -> Tuple[int, Iterable[Compil
if not os.environ.get('PROS_TOOLCHAIN'):
ui.logger(__name__).warn("PROS toolchain not found! Please ensure the toolchain is installed correctly and your environment variables are set properly.\n")
ui.logger(__name__).error(f"ERROR WHILE CALLING '{make_cmd}' WITH EXCEPTION: {str(e)}\n",extra={'sentry':False})
if not suppress_output:
if not suppress_output:
pipe.close()
sys.exit()
if not suppress_output:
Expand Down
10 changes: 5 additions & 5 deletions pros/ga/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def send(self,action):
'ni': 0
}

session = FuturesSession()
session = FuturesSession()

#Send payload to GA servers
#Send payload to GA servers
future = session.post(url=url,
data=payload,
headers={'User-Agent': agent},
Expand All @@ -71,13 +71,13 @@ def set_use(self, value: bool):
self.useAnalytics = value
self.cli_config.ga['enabled'] = self.useAnalytics
self.cli_config.save()

def process_requests(self):
responses = []
for future in as_completed(self.pendingRequests):
try:
response = future.result()

if not response.status_code==200:
print("Something went wrong while sending analytics!")
print(response)
Expand All @@ -92,4 +92,4 @@ def process_requests(self):
return responses


analytics = Analytics()
analytics = Analytics()
2 changes: 0 additions & 2 deletions pros/serial/ports/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,3 @@ def __str__(self):
return f"Port not found: Could not open port '{self.port_name}'. Try closing any other VEX IDEs such as VEXCode, Robot Mesh Studio, or " \
f"firmware utilities; moving to a different USB port; {extra}or " \
f"restarting the device."


72 changes: 36 additions & 36 deletions pros/serial/ports/v5_wireless_port.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
from typing import *

from pros.serial.devices.vex.v5_device import V5Device
from pros.serial.ports import BasePort, DirectPort


class V5WirelessPort(BasePort):
def __init__(self, port):
self.buffer: bytearray = bytearray()

self.port_instance = DirectPort(port)
self.device = V5Device(self.port_instance)
self.download_channel = self.device.DownloadChannel(self.device)
self.download_channel.__enter__()

def destroy(self):
self.port_instance.destroy()
self.download_channel.__exit__()

def config(self, command: str, argument: Any):
return self.port_instance.config(command, argument)

# TODO: buffer input? technically this is done by the user_fifo_write cmd blocking until whole input is written?
def write(self, data: bytes):
self.device.user_fifo_write(data)

def read(self, n_bytes: int = 0) -> bytes:
if n_bytes > len(self.buffer):
self.buffer.extend(self.device.user_fifo_read())
ret = self.buffer[:n_bytes]
self.buffer = self.buffer[n_bytes:]
return ret

@property
def name(self) -> str:
return self.port_instance.name
from typing import *

from pros.serial.devices.vex.v5_device import V5Device
from pros.serial.ports import BasePort, DirectPort


class V5WirelessPort(BasePort):
def __init__(self, port):
self.buffer: bytearray = bytearray()

self.port_instance = DirectPort(port)
self.device = V5Device(self.port_instance)
self.download_channel = self.device.DownloadChannel(self.device)
self.download_channel.__enter__()

def destroy(self):
self.port_instance.destroy()
self.download_channel.__exit__()

def config(self, command: str, argument: Any):
return self.port_instance.config(command, argument)

# TODO: buffer input? technically this is done by the user_fifo_write cmd blocking until whole input is written?
def write(self, data: bytes):
self.device.user_fifo_write(data)

def read(self, n_bytes: int = 0) -> bytes:
if n_bytes > len(self.buffer):
self.buffer.extend(self.device.user_fifo_read())
ret = self.buffer[:n_bytes]
self.buffer = self.buffer[n_bytes:]
return ret

@property
def name(self) -> str:
return self.port_instance.name
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.2
3.4.2
2 changes: 1 addition & 1 deletion win_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.2.0
3.4.2.0

0 comments on commit 141f50b

Please sign in to comment.